Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #181794

    I would like to accomplish this same thing Peter provided here…

    http://www.kriesi.at/support/topic/display-media-item-title-instead-of-media-item-description-in-lightbox/#post-178730

    but for it to happen in the new masonry galleries.

    the code change in gallery.php doesn’t translate over to the masonry_gallery.php simply. I can’t find the code below to swap

    //$title = trim($attachment->post_title) ? esc_attr($attachment->post_title) : ""; original code commented out
    //$description = trim($attachment->post_content) ? esc_attr($attachment->post_content) : ""; original code commented out
    $description = trim($attachment->post_title) ? esc_attr($attachment->post_title) : "";
    $title = trim($attachment->post_content) ? esc_attr($attachment->post_content) : "";

    So the change must be different. I want to display the media item title in the lightbox when it is viewed. That way If I turn off the hover effect that displays the media title there is still away for the viewer to see the image title when viewing the lightbox.

    My site is http://jackandaddi.com/gallery/rykowski-family/
    And please account for the change to take place in a child theme setup.
    thank you.

    #182360

    Hey allegrabillings!

    Please open up wp-content\themes\enfold\config-templatebuilder\avia-shortcodes\masonry_entries.php and delete the entire code. Then paste the code from: https://gist.github.com/InoPlugs/1ce9b14b6c37e93015e5

    Regards,
    Peter

    #182501

    Hey Peter thanks for the code. It didn’t appear to work though. If you visit the link in my previous post that will take you to a masonry gallery page to test. The code you gave is still in place in my child theme for testing.

    just for clarity, I noticed you had me change masonry_entries.php instead of masonry_gallery.php, now I admittedly have no idea what to change but as there is only two masonry scripts and two masonry elements (entires and galleries) I figured we would be changing the gallery php as that is were I want the media item title to show in the lightbox.

    If we do in fact need to change the entires then disregard below. But if that was an oversight than please advise further. There was likely more you changed in the code you provided for the entires but the only thing I noticed on first glance was this…

    				if(!empty($attachment))
    				{
                        $alt = get_post_meta($thumb_ID, '_wp_attachment_image_alt', true);
                        $alt = !empty($alt) ? esc_attr($alt) : '';
                        $title = esc_attr(get_the_title($thumb_ID));
     
    					if(isset($attachment[0]))
    					{

    you added the 3 lines in the middle. I thought maybe I could copy this work in the masonry_gallery php but didn’t find a similar location, and there was likely more you changed that I wasn’t seeing anyway.

    1. So please advise how to make the change visible in a masonry gallery element, so the title of the image shows in the lightbox.

    2. Also if the change to the masonry_entries was by mistake, what will that change do? If it does in fact show the title of anything pulled by a masonry entry that is opened in the lightbox I can just leave it, as I would like that functionality. I just don’t have any masonry entries on my site to test. But I could make one of course.

    Thank you in advance for looking into this further.
    Cheers

    #182866

    Hey!

    masonry_gallery.php just extends masonry_entries.php and you need to modify masonry_entries.php if you want to modify the gallery output. If you want to show the title of the image in the lightbox use the code I posted in my last answer and replace

    
                    if($post_type == 'attachment' && strpos($html_tags[0], 'a href=') !== false)
                    {
                        $linktitle = 'title="'.esc_attr($description).'"';
                    }
                    else if(strpos($html_tags[0], 'a href=') !== false)
                    {
                        $linktitle = 'title="'.esc_attr($the_title).'"';
                    }
    

    with

    
                    if($post_type == 'attachment' && strpos($html_tags[0], 'a href=') !== false)
                    {
                        $title = esc_attr(get_the_title($thumb_ID));
                        $linktitle = 'title="'.esc_attr($title).'"';
                    }
                    else if(strpos($html_tags[0], 'a href=') !== false)
                    {
                        $linktitle = 'title="'.esc_attr($the_title).'"';
                    }
    

    By default Enfold will display the alternative text in the lightbox (instead of the image title) because of consistency reasons.

    Regards,
    Peter

    #183506

    This now works perfectly, thanks Peter.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘display media item title in the lightbox’ is closed to new replies.