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

    there was a title fix for image galleries which works great – and i want now transform that to horizontal Gallery. – So that on having the lightbox image shown underneath is the alt Attribut shown instead of image title.

    So I varied the known code a little.

    
    
    function horizontal_gallery_title_fix(){
    ?>
    <script>
    (function($){
        $(window).load(function() {
          $('img.av-horizontal-gallery-img').each(function(){
                var lin = $(this).attr('alt');
                $(this).attr('title',lin);
            });
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'horizontal_gallery_title_fix');

    i see that it works in source code – the code replaces the image title with the alt attribut. – But on Lightbox there will be shown original image title instead. Don’t know why?

    #1013023

    is there a way to style the horizontal gallery a bit nicer on small screens?

    edit : i did it by showing the horizontal gallery only on screens larger than 768px
    on screens smaler there will be a masonry instead.

    #1013056

    Hey!

    i see that it works in source code – the code replaces the image title with the alt attribut. – But on Lightbox there will be shown original image title instead. Don’t know why?

    As far as I know the lightbox script pulls the title from the link (a href element) if a title attribute is set. The code can be found in enfold\js\avia-snippet-lightbox.js around line 43+

    
      var title = item.el.attr('title');
      if(!title) title = item.el.find('img').attr('title');
    

    Thus you can either remove the title attribute from the lightbox link or (probably the better solution) you simply add the image title/alt attribute as link title. You can use a code like

    
          $('img.av-horizontal-gallery-img').each(function(){
                var lin = $(this).attr('alt');
                $(this).attr('title',lin);
                $(this).next('.av-horizontal-gallery-link').attr('title',lin);
            });
    

    Best regards,
    Peter

    #1013223

    it works in so far all ok. But i wonder why the last line is neccessary:
    This works on gallery as i often use it :

    function gallery_title_fix(){
    ?>
    <script>
    (function($){
        $(window).load(function() {
          $('.lightbox-added img').each(function(){
                var lin = $(this).attr('alt');
                $(this).attr('title',lin);
            });
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'gallery_title_fix');

    why this line:
    $(this).next('.av-horizontal-gallery-link').attr('title',lin);

    did the trick and on gallery this is not needed?
    Anyway it runs now.

    #1013225

    ok – now i see : the image that goes to the lightbox is on that case the image on av-horizontal-gallery-link

    so it might only need to change the title on that :

    $('img.av-horizontal-gallery-img').each(function(){
                var lin = $(this).attr('alt');           
                $(this).next('.av-horizontal-gallery-link').attr('title',lin);
            });

    this line $(this).attr('title',lin); is obsolete – and only for hovering the highlighted horizontal gallery image needed
    thanks

    #1013227

    Hi!
    Glad you found the right code :)

    Regards,
    Peter

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.