• Resolved redkite

    (@redkite)


    Is there a way to exclude certain images from sizing down to a certain width and height, like a hero image uploaded to a block?

    Or should I turn on resizing when the project is ready to launch, if it works so that any images added after that by the client will be resized? I guess I’d still need an exclusion though in case they tried to optimize everything?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Pedro

    (@petredobrescu)

    Hello @redkite,

    You should be able to achieve that, with some custom coding (that decides what needs to be excluded) and this filter:

    apply_filters('shortpixel/api/request', $requestParameters, $item_id);

    In short, it filters the parameters sent to the optimization API (through $requestParameters), described in detail here: ShortPixel Reducer API; $item_id contains the ID of the Media Library item or the ID of the Custom Media item (when used). Basically, this filter can be used to alter any parameters sent to the API, depending on the needs. For example, you can set different resize parameters for different post types or certain images (you need to somehow identify those images from your custom code), you can set different compression levels, remove EXIF or not, covert WebP/AVIF, and pretty much any other parameter that is sent to the API for a specific image (together with all its thumbnails).

    Alternatively, you can use the exclusions section, but that will exclude the image from the entire processing (meaning that it will not only be excluded from resizing, but also from optimizing, generating WebP/AVIF, etc.).

    Looking forward to getting your confirmation about this!

    Thread Starter redkite

    (@redkite)

    Understood. Just to confirm, if I set a resizing limit to 1200px wide, that *will* size down the 1900px-wide hero image I upload into a block, right?

    Plugin Author Pedro

    (@petredobrescu)

    Yes, that’s the way the resize should work.

    However, please note the following detail: depending on your theme, there might be thumbnails that are supposed to be generated with higher sizes (let’s take the 2048×2048 one). In this case, the thumbnail (that is generated by WordPress itself) will be named filename-2048x2048.jog, but the actual file will be resized according to the resize settings from ShortPixel (1200px in your case).

    I hope that helps!

    Thread Starter redkite

    (@redkite)

    Got it, thanks for clarifying.

    Plugin Author Pedro

    (@petredobrescu)

    My pleasure!

    I’ll mark this thread as Resolved now. Please write back here if you still have questions on this topic, otherwise, you can open a new thread!

    All the best,
    Pedro/ShortPixel team

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude certain images from resizing?’ is closed to new replies.