• Hi,

    I’ve built a WordPress plugin that adds a new section to a post that can optionally be filled out to show the detail’s of a book at the top of the post. The plugin contains its own functionality for uploading the book’s cover image.

    I’m trying to upgrade the plugin to provide the option for showing a thumbnail of the book’s cover in the archives, and I’m struggling with the best way to do this. Here are the options that I think I have:

    1. Use the Featured Image as the thumbnail.
    2. Resize the image when the user uploads the cover using the plugin’s uploader.

    The problem with using the Featured Image is that it is outside of the plugin’s functionality, and I can’t rely on people having this enabled in their theme or even using the Featured Image for the book’s cover. For that reason, I really don’t want to do things this way.

    The disadvantage of the second option is that the user has to use the plugin’s upload functionality in order for the thumbnail to be generated.

    Can anyone see a third option where thumbnails can be generated for the book covers, even if those covers weren’t uploaded using the plugin’s functionality?

    Thx.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    If you use add_image_size() to define a new size, that new size will be generated when any image is uploaded through the default media uploader. Thus the resized cover image will be available regardless of which uploader was used. The draw back is this image size is generated for all uploaded images, even those for non-cover images.

    Thread Starter Book Wookie

    (@bookwookie)

    You’re right. I didn’t realize it would still save the thumbnail if uploaded outside the plugin. I’m not crazy about the idea of saving thumbnails for every image, so I’m undecided whether I’m going to do it this way or just try to make it clear that the plugin’s uploader should be used if they want thumbnails to be generated.

    Regardless, to get the URL for the thumbnail, am I correct in assuming I have to look in the uploads folder? The thumbnail URL doesn’t appear to be in the database. I noticed that, when I upload an image, four thumbnails are generated. One is for my plugin and another I’m guessing is the featured image. Is it safe to assume that some other plugins are generating the other two?

    Thread Starter Book Wookie

    (@bookwookie)

    Ah, I just discovered wp_get_attachment_image. Much easier!

    Thx.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin Design – Generating Thumbnails’ is closed to new replies.