Captions – I am losing my mind
-
Love the plugin but I can’t get captions to work. Have spent hours now.
It seems all scripts except for PrettyPhoto picks up the link title attribute and shows that as the caption when images are enlarged.
i.e.<a title="whatever is in here will by used as the caption by Responsive Lightbox"><img class=" ... ></a>
That’s not very easy to work with. No theme I know of asks for the link title attribute when new images are uploaded to WordPress.
When I upload an image, I fill in the CAPTION field and WordPress kindly displays this as the caption on my single image in my post.
But to get the exact same caption to show below the enlarged (lightbox) version of the image, I will have to go into the code and manually duplicate the caption text as the link title.
To make life a lot easier, I really want to use the content of either the CAPTION, ALT or TITLE field as the lightbox caption. But I cannot figure out how to do this.
I have tried all settings and also adding this bit of code to functions.php.
function modify_attachment_link( $html, $id ) { $att_alt = get_post_meta($id, '_wp_attachment_image_alt', true); $html = str_replace( '<a href', '<a title="'.$att_alt.'" href', $html ); return $html; } add_filter( 'wp_get_attachment_link', 'modify_attachment_link', 10, 2);
No luck. Only the link title will show up as the caption.
I can see that dFactory has previously told people to modify their themes to get this to work. But I don’t know what to do.
Can anyone help? Thanks …
- The topic ‘Captions – I am losing my mind’ is closed to new replies.