Show caption text instead of title in Fancybox for WordPress plugin
-
Hi,
I saw that Fancybox for WordPress is using image titles to show text on below of the image and I was looking for showing caption text. I searched it and found an old solution. But it wasn’t working. So, I upgraded it to new version of fancybox.
This code shows caption text instead of title if there is caption text attached to image.
1) open “/wp-content/plugins/fancybox-for-wordpress/fancybox.php”
2) find “jQuery.fn.getTitle = function() { …” line(227. line)
3) change it with below function :jQuery.fn.getTitle = function() { // Copy the title of every IMG tag and add it to its parent A so that fancybox can show titles var arr = jQuery("a.fancybox"); jQuery.each(arr, function() { var title = jQuery(this).children("img").attr("title"); if ( jQuery( this ).children("img").next().hasClass( 'wp-caption-text' ) ) { title = jQuery( this ).children("img").next().text(); } jQuery(this).attr('title',title); }) }
voila!
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Show caption text instead of title in Fancybox for WordPress plugin’ is closed to new replies.