How to Fetch Image Title/Description/LongDesc?
-
Hello All,
I am looking for a way to change the way images are inserted in blog posts. I have a couple of issues:- The image uploaded uses the CSS class ‘alignright’, that is rendered correctly, but not in the editor. I would like to replace that with an “align=’right'” instead
- Currently the title is hardcoded in the post – for me that doesn’t really make sense: the media library already has a title, alt text, and long description. When I change anything in the media library, that change should be reflected in all posts, which it currently doesn’t (for me)
- For links to images, I want to add the title to the A-tag so the title shows up in the lightbox overlay
Currently I run something like:
add_filter('the_content', 'addlightboxrel_replace'); function addlightboxrel_replace ($content) { global $post; //$pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; $pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)title=('|\")(.*?)('|\")(.*?)<\/a>/i"; $replacement = '<a$1href=$2$3.$4$5 title=$8$9$10 rel="lightbox[%LIGHTID%]"$6>$7title=$8$9$10$11</a>'; $content = preg_replace($pattern, $replacement, $content); $content = str_replace("%LIGHTID%", $post->ID, $content); return $content; } ?>
This would insert the lightbox tag and a title. Problem now is: how do I set the title attribute of images to the title from the media library / alt text / long description? Shouldn’t there be a switch for that?
Cheers,
Thorsten
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to Fetch Image Title/Description/LongDesc?’ is closed to new replies.