Fairweb

Développement WordPress, WordPress Mu, BuddyPress

fw-post-image

Description

This plugin does not work with WordPress version prior to 2.9 !
Since WordPress 2.9, you can choose which image will represent a post and will be displayed as thumbnail. This plugin allows backward compatibility for your former posts.
it filters on the_post_thumbnail() function. If no post thumbnail is defined, the plugin will get first image belonging to post. If it still doesn’t find any image, it will scan for the first image found post content.

The image will be displayed according to the arguments (size and attributes) set when calling the_post_thumbnail().

Installation

  1. Upload the `fw-post-image` folder to the `/wp-content/plugins/` directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Make sure your template supports post image by adding in the functions.php file of your theme add_theme_support('post-thumbnails');
  4. Put the template tag `the_post_thumbnail($size, $attr)` in the loop in your template where you want the post image to appear. For example :
    <?php the_post_thumbnail('thumbnail', 'class=alignleft'); ?>

Frequently Asked Questions

The plugin does not work

  1. Make sure you are running WordPress 2.9 or above
  2. Make sure your template supports post image by adding `add_theme_support(‘post-thumbnails’);` in the functions.php file of your theme.
  3. Put the template tag `the_post_thumbnail($size, $attr)` in the loop in your template where you want the post image to appear. For example :

<?php the_post_thumbnail('thumbnail', 'class=alignleft'); ?>

Changelog

1.2

  • Prevent error on getimagesize (line 92) when scanning post content for an image and finding an image which does not exist.

1.1

  • Changed filter name for post_thumbnail_html (previously post_image_html)
  • Changed action name for begin_fetch_post_thumbnail_html(previously begin_fetch_post_image_html)
  • Changed action name for end_fetch_post_thumbnail_html(previously end_fetch_post_image_html)

1.0

  • First plugin release

Download

Download the plugin from the WordPress Plugin Repository


Share

23 Comments

  1. This looked great, but it’s not working for me. I know post thumbnails are working because I can create a new post with a post thumbnail, and the thumbnail displays. I’m using K2 1.0.3. My loop PHP contains:

    the_post_thumbnail( array( 100, 100 ), array( 'class' => 'alignleft' ) );

    But I’ve also tried changing it to:

    the_post_thumbnail($size, $attr)

    I’m on WordPress MU 2.9.1.1

  2. I’ll check with your syntax. However, can you tell me which php version you are using ? Does the script display an error or notice in debug mode ?

  3. Ok I’ve just checked on a single WP install with the following syntax and it works fine.
    the_post_thumbnail( array( 100, 100 ), array( 'class' => 'alignleft' ) );

    Are you saying it works when you disable the plugin ?

  4. Same syntax tested on WP mu 2.9.1.1 on default theme, it works. So I guess the problem either comes from your php version or from your template (or a plugin conflict).

    Please let me know if you find something.

  5. It’s possible some of my jQuery was conflicting with it. Standard post thumbnails would work whether fw-post-image was activate. But I ended up switching plugins and found something that worked for me.

  6. I want to use your plugin with category posts widget… it doesn’t work out of the box… but it does with 1 tiny modification …

    if (
    function_exists(‘the_post_thumbnail’) &&
    current_theme_supports(“post-thumbnails”) &&
    $instance["thumb"] &&
    has_post_thumbnail()
    ) :
    ?>
    <a href="” title=”">
    id ); ?>

    just remove the condition

    && has_post_thumbnail()

    So even if it doesn’t have a thumbnail, the_post_thumbnail still gets called
    and your plugin takes care of auto generating the thumbnail from post images…

    awesome

    now i can blog from email through xmlrpc and still have post thumbnails show up, even in the sidebar !!!

    Love your plugin!

  7. Hi Myriam,

    Great idea for a plugin, would love to use it
    Unfortunately when I tried to activate it I got this error:

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in …/wp-content/plugins/fw-post-image/fw-post-image.class.php on line 8

    I am using WP 2.9.1 and PHP 5.1.
    Please let me know if you fix the problem.
    Thanks for your time and effort, highly appreciated.

    best,
    Julian

  8. My mistake Myriam, I found out that the server i am working on is running PHP 4.4. I will let you know how things work out once i switch to PHP 5.

    best,
    Julian

  9. Plugin works to a degree. First, in the admin section after clicking update for my post my screen goes blank. Second, how do you change the size of the thumbnail. Third, I’m guessing should be added to the function with the php tags. Fourth, do you place or this in the loop.

  10. David,
    I’m not sure I understand everything in your comment but I’ll try to help you. This plugin works with WordPress 2.9 minimum and Php 5.
    1) Blank screen : desactivate plugins one by one to check on plugins compatibility. This never happened to me so I cannot reproduce the error.
    2) the_post_thumbnail function is a core WordPress function. You’ll get information in the WordPress codex : http://codex.wordpress.org/Template_Tags/the_post_thumbnail
    3) I don’t understand what you mean, please explain
    4) This function is used within the loop.

  11. Hi Fairweb, great plugin… but: is possible to print image url only?
    (Ok… excuse me for my very bad english)

  12. Just more question: is there a way to display not only attached files but images added by media library too?

  13. Plugin is great!
    I would like to use more than one attribute. Is this possible?

    Thanks,

    Steve C

  14. Manuel, the plugin is not really there to add new features but to make sure the new post thumbnail feature which appeared in WP 2.9 worked with former posts on ancien blogs. If you want to display any image from the media library as a post thumbnail, you will need to choose it from your post and click on “choose as thumbnail”. This will only be possible if your theme allows it.

  15. Stephen, this function is the original WP function and should work just like this one :
    http://codex.wordpress.org/Template_Tags/the_post_thumbnail

    However, I’d say there is a mistake in the codex as the second argument is not an int but a string or array, which means it does bear more than one attribute.

  16. Bonjour,
    tres bon plugin mais même probleme que David, page blanche aprés chaque validation (qui est prise en compte quand même). Pas d’autre plugin fautif sauf un peut-être que je ne peux desactiver sans tout perdre : Executable php widget . Suis sur Mamp en local et firefox.
    Ravi de voir qu’il y a une spécialiste wordpress à moins de 80 km !

  17. Steph, effectivement, nous sommes voisins :)
    Quelle version de php utilises-tu ? Quelle version de WordPress ?
    Je n’arrive pas à reproduire cette erreur. Peux-tu tester sur un site de test en local, donc dans le même contexte, mais sans autre plugin activé ? Ca me permettrait de savoir s’il s’agit d’un contexte de serveur ou d’une incompatibilité avec des plugins.
    Merci de répondre à toutes ces questions pour que je puisse aider ;)

  18. Bon je retape parce que le fait de s’abonner m’ a “manger” le message je crois.
    Merci de ta réponse rapide, chère voisine :-)
    Mon cas se complique : tous plugin désactivés, même problème. Je reviens au theme standard, ça marche ! Comment un theme peut influer sur l’admin ?
    Derniere plaisanterie de WP, plus de tableau de bord non plus. Bref ton plugin est hors de cause, à moins qu’il n’installe quelque chose quelque part, non ?
    sinon OSX, mamp en local, php5 et wp2.9 à jour, en fr.

  19. probleme résolu.
    Le fichier fonction du theme avait un probleme au niveau de la declaration post tumbnails. C’était donc une conséquence indirecte de l’installation de ton plugin. tout est rentré dans l’ordre. Site visible : http://www.directnature.fr
    Dernier truc, ne pas oublier de modifier le fichier ht acces à la mise en ligne. Passer en php 5.
    (je me suis fait avoir …)
    a+ et merci

  20. Great plugin. Very useful for those upgrading to the new thumbnail feature on 2.9.
    One sugestion: It would be great if I could set a default image for those imageless posts.

    Thank you for the plugin.

    • Thanks for you suggestion Niva. Actually I don’t want my plugin to have additional features. It’s just meant to have a smooth upgrade and just over-charges the core wordpress function. This means that if another plugin which does what you want is also used, it should still work.

  21. Hi,

    How can I plug this plugin into Thesis theme ?

    Thanks !

  22. And I thought I was the sensible one. Thanks for setting me satrgiht.

Leave a Reply

Required fields are marked *.

*