Using the image caption as the title in slimbox
-
Hi there
I’ve found the following function to automatically apply the rel, “lightbox-gallery” to all my images that have been uploaded to pages using a particular template.
However, when clicking on the images, the slimbox displays the post title as the ‘title’ of the slimbox rather than the caption/title that was entered on the image itself.
How can I grab the image title instead?
//lightbox add_filter('the_content', 'my_addlightboxrel'); function my_addlightboxrel($content) { global $post; $pattern ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; $replacement = '<a$1href=$2$3.$4$5 rel="lightbox-gallery" title="'.$post->post_title.'"$6>'; $content = preg_replace($pattern, $replacement, $content); return $content; }
- The topic ‘Using the image caption as the title in slimbox’ is closed to new replies.