Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi John,

    Yes, that’s right. If no images are found, my plugin won’t display an image. However, from version v2.1.0 (released yesterday) you can select a custom thumbnail following this tutorial.

    There’s a hidden hack included on v2.1.0 that you can use to have WordPress Popular Posts generate a thumbnail automatically if a post doesn’t have a thumbnail selected by you. If you want to activate this feature, follow these steps:

    1. Open wordpress-popular-posts.php using an editor such as Notepad or Adobe Dreamweaver.
    2. Around line 686, you will find this:

      // Uncomment this block to have WordPress Popular Posts
      // create an image when there is no thumbnail selected
      // by user for the user. Otherwise, WPP will use the
      // Post Thumbnail feature to retrieve it.

      Follow the instructions and uncomment the code block below. Also, make sure you comment out the code block that starts around line 699 to disable the current behavior (no image if no thumbnail has been selected).

    3. Save changes.

    Give that a try and let me know if you need further help. Might consider adding a default thumbnail on the next release, though.

    Thanks for your feedback!

    Thread Starter Arash

    (@john25)

    Thank you for your reply.

    I just updated to 2.1.0 and change the code, but this does not fix the problem.

    I am looking for something like:

    If there is an image please make a thumbnail using timthumb.php with the image in the post (what this pluging does).

    If there is no image in the post (not all post have images) then use timthumb.php to resize default.jpg.

    The code you suggested does not seem to do that.

    I see. Let me explain myself a bit better.

    The newest version of WordPress offers a new feature called Post Thumbnail. With it, you can select a personalized thumbnail for each post.

    With version 2.1.0, I wanted to take advantage of this functionality and let people choose their desired image instead of relying on timthumb.php since WordPress already has the thumbnail generation feature built-in.

    If someone selects a thumbnail for their post, my plugin will use that. If there’s no image selected, WordPress won’t show anything (and that’s what you don’t want, right?).

    The hack I told you about tells WordPress Popular Posts to build an image from the first image attached to the post if there’s no thumbnail selected by the user. However, I didn’t contemplate the possibility that there was no image attached to the post. I’ll include a fix for that in the next release of my plugin (v.2.1.1). For the moment, you’ll have to hack my plugin to make it work that way:

    1. In wordpress-popular-posts.php, find:

      $thumb = “”;

      … and change it to:

      $thumb = "<a href=\"".get_permalink($wppost->ID)."\" class=\"wppgen\" title=\"". $title_attr ."\"><img src=\"". $this->pluginDir . "/scripts/timthumb.php?src=path/to/your/defeault/thumbnail.jpg&h=".$instance['thumbnail']['height']."&w=".$instance['thumbnail']['width']."&zc=1\" alt=\"".$title_attr."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$instance['thumbnail']['width']."\" height=\"".$instance['thumbnail']['height']."\" "."/></a>";

      … where path/to/your/defeault/thumbnail.jpg is the full path of image you wish to use as default if my plugin can’t find one for you.

    2. Save changes.

    That should do it.

    Thread Starter Arash

    (@john25)

    Thank you so much! That is exactly what I was looking for.

    p.s Also thank you for the education 🙂 I just learned something about the new wordpress.

    No problem, glad to know that everything’s working as you expect!

    Enjoy!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WordPress Popular Posts] Default Thumbnail’ is closed to new replies.