WordPress.org

Ready to get started?Download WordPress

Forums

Feature: Restrict thumbnail sizes for specific post tpes (3 posts)

  1. pmdci
    Member
    Posted 3 years ago #

    I would like to do is to restrict different thumbnail sizes for especific post types.

    So, as an example:
    * Thumbnails for my custom post type would always be 150x150
    * Thumbnails for my default post type would always be 200x200

    When adding the function for thumbnains in my functions.php file for my theme I can use the following code:

    add_theme_support( 'post-thumbnails', array( 'post', 'partner' ) );
    set_post_thumbnail_size(150,150,true); // 150x150 hard crop mode

    So I can have thumbnails of size 150x150 for my post types post and partner.

    I know I can add multiple thumbnail sizes with a code such as:
    add_image_size(‘TinySize’, 50, 50, true);

    But the point of my suggestion is to be able to configure my WP site so posts of type 1 can have thumbnails of size A, B, C. While posts pof type 2 can have thumbnails of size X, Y, Z.

    What do you guys think?

  2. jwinslow
    Member
    Posted 3 years ago #

    I have only been working with WordPress for a week so I may not be qualified to answer this however I am not without ideas, I understand any additional functionality must be added to the ini.php file and added consecutively to the specific file and method that calls the image size.

    As I would see this, you would mimic or duplicate the code that uses the default size image, adding a bitmapmatrix filter which you can find rather effective examples online, and add this to your method. This would allow you to reuse the same image on a different scale from the same source. In the instances where you would want to call the "custom" thumbnail you would need to find that section of code and add the condition. I hope this idea helped a little however as I said, Im not very qualified.

  3. pmdci
    Member
    Posted 3 years ago #

    Your comments are welcome. Brainstorming is always good.

    My point here is, however, trying to minimize the amount of file duplication and redundancy.

    If I allow for thumbs of 150x150 and 50x50 for instance, this would be for all post types configured.

    Imagine if I only want 50x50 for one type of post. This post type would nonetheless have both thumbnail sizes.

    I think this could be vlaidated as a possible caveat, particularly for users with space/bandwidth limitations in their servers.

Topic Closed

This topic has been closed to new replies.

About this Topic