[resolved] Featured image (3 posts)

  1. Preeminent
    Posted 3 years ago #

    So if I'm not using the_content in my theme, and just the_post_thumbnail, this plugin wouldn't work for me, right?


  2. kylereicks
    Plugin Author

    Posted 3 years ago #

    Good question.

    Short answer, no... or rather, you are correct in your assumption. The plugin wont look through images outside the_content, and I don't plan on expanding it to hook into other filters by default.

    Longer answer, soon. Hooking and structuring the plugin to be easily extended by theme authors is the major goal of the next feature release. I will certainly take your question into account when thinking about extension use cases.

    Longest answer yes. Even though the current stable version of the plugin is not well hooked, you can still take advantage of some of it's functions in your theme.

    If, for example, your post_thumbnail is the same size as your thumbnail, the following code in your functions.php file might just do the trick. (It's working for me in a single test case, but I haven't tested it extensively)

    add_filter('post_thumbnail_html', array('Picturefill_WP', 'replace_images'));
    add_filter('post_thumbnail_html', 'add_attachment_id_to_post_thumbnail_class', 9, 5);
    function add_attachment_id_to_post_thumbnail_class($html, $post_id, $post_thumbnail_id, $size, $attr){
       return preg_replace('/class="([^"]+)"/', 'class="$1 size-thumbnail wp-image-' . $post_thumbnail_id . '"',$html);

    If you are so inclined, give that a shot and let me know if it works for you. If not, I have another idea that we could try that target the post_thumbnails more directly, but I'd like to try it out myself before I post it as a possible solution.

  3. kylereicks
    Plugin Author

    Posted 3 years ago #

    I'm going to mark this issue as resolved with version 1.2.0

    See the [Extending Picturefill.WP](https://github.com/kylereicks/picturefill.js.wp#extending-picturefillwp) subsection of the GitHub repository for an example of how to extend the plugin and add additional image sizes if desired.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Picturefill.WP
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.