Wordpress function for standard link rel on images in a post
I'm using colorbox t开发者_开发技巧o view larger images on my wordpress site. For this to work, I've got to insert the image to the post, close the wordpress media popup window, click on the image, click on the "Edit image" icon, tabbing into Advanced Settings and adding "attachment" under the option field "link rel".
NOW the thumbnail is connected to the lightbox through link rel="attachment". Many unnecessary steps which are also advanced for the average user.
Anyone know a solution that adds the link rel="attachment" auto when adding an image into a post? Other solutions are also appreciated.
See the thumbnails and markup here: http://pokerstrategy.org.uk/news/2011-pca-main-event-final-table-determined
JS for colorbox: $("a[rel='attachment']").colorbox();
Instead of jQuery, perhaps you could add a filter to the_content, so that when Wordpress loads posts it'll do it automatically opposed to w/ jQuery? I was thinking something like this:
add_filter( 'the_content', 'lightboxfix');
function lightboxfix ($content) {
$content = preg_replace("/<img/","<img rel=\"attachment\"",$content,1);
return $content;
}
Basically, it grabs the post contents, changes all <img..
elements to have <img rel="attachment"..
. I would give it a shot.
精彩评论