Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1327979

    We are wondering if it is possible to dynamically add a CSS class for animated every image element on the website (or every column) instead of doing it manually in each element. Is this possible through CSS pseudoclasses or adding a PHP function?

    Thank you!
    Candy

    #1328064

    Hey Candy,
    Thanks for your question, it would be possible but all elements don’t share the same animation classes and typically multiple classes are required, for example on a basic image element the top-to-bottom animation requires 3 classes. In my test this script will add this animation for all images in a image element:

    function custom_animated_image() { ?>
        <script>
    (function($){
      $('.avia-image-container').addClass('avia_animated_image avia_animate_when_almost_visible top-to-bottom');
    })(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'custom_animated_image');

    You can test this by adding this code to the end of your functions.php file in Appearance ▸ Editor

    Best regards,
    Mike

    #1328249

    Thanks, Mike! That seemed to work! It seems a little slow / buggy though. You can see that working on 5 images on this page:

    Are there any downsides to this approach in terms of performance or otherwise that you can think of?

    #1328352

    Hi,
    This script is running after the DOM, so you are giving on this end instead of using the element options when the page is built.
    So this would be ok if after placing hundreds of images you realized that you wanted the animation, but I would not recommend it as an excuse to not select the option when the page was built the first time.
    Perhaps using Custom Element Templates would be better so your elements already have your basic options defined.

    Best regards,
    Mike

    #1328376

    Got it thanks for the clarification!

    #1328464

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Possible to add Animation to Every Image with CSS or PHP?’ is closed to new replies.