Pulling out caption from post image
-
I have an old plugin that I like (Drop Caps), and for the most part it works well (see my site. The biggest problem (and I’ve seen this with newer, similar plugins) is that on posts where the first element in the post is an image from the media library, the plugin puts a drop cap on the caption tag rather than the first paragraph of text in the post.
I can see why this is happening – there’s a regex that looks for the first
<p>
tag and then drop caps the first capital letter after that tag.What I’d like to do is set up a condition in the plugin’s function that looks for the caption and if the <p> is a caption, it’s not included, but I don’t know how to call image caption to do that.
Here is the existing code for the “not included” elements from the plugin:
function is_excluded($options){ global $post; $excluded_cats=$options['excluded_cats']; $excluded_ids=$options['excluded_ids']; $id=$post->ID; $title=$post->post_title; $name=$post->post_name; if(in_array($id,$excluded_ids)) return true; if(in_array($title,$excluded_ids)) return true; if(in_array($name,$excluded_ids)) return true; $categories=get_the_category(); foreach($categories as $category){ $cat_id=$category->term_id; $cat_slug=$category->slug; $cat_name=$category->name; if (in_array($cat_id,$excluded_cats)) return true; if (in_array($cat_slug,$excluded_cats)) return true; if (in_array($cat_name,$excluded_cats)) return true; } return false; }
So the function can say “don’t include if the item is a post title or post name,” but can you think of a way to say “don’t include if the item is an image caption?
- The topic ‘Pulling out caption from post image’ is closed to new replies.