• Resolved tonyko33

    (@toniko33)


    Hi,

    I wonder if there is a way to disable the creation of images automatically created by OceanWP when uploading an image with wordpress.

    if i use the code below in the function.php folder of my childtheme, will it work?

    // Remove or unregister unused OceanWP Image Sizes
    function blorax_remove_intermediate_image_sizes($sizes, $metadata) {
    $disabled_sizes = array(
    'ocean-thumb-m',
    'ocean-thumb-ml ',
    'ocean-thumb-l'
    );
    // unset disabled sizes
    foreach ($disabled_sizes as $size) {
    if (!isset($sizes[$size])) {
    continue;
    }
    unset($sizes[$size]);
    }
    return $sizes;
    }
    // Hook the function
    add_filter('intermediate_image_sizes_advanced', 'blorax_remove_intermediate_image_sizes', 10, 2);

    Is there a risk that it will break the theme or my site?

    Thank you for advice.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Shahin

    (@skalanter)

    Hello @toniko33,

    Thank you for reaching out,

    Before anything else, please keep in mind:
    You should not test the code you provided directly on your live/production site. If an error occurs, it could break the site. Instead, test the code in a staging or test environment first. Once everything is confirmed to work correctly, you can safely apply your changes to the live site.

    __________

    Regarding the code you provided, there might be a few issues:
    One is the extra space in ocean-thumb-ml.
    Also, remember that intermediate_image_sizes_advanced only affects newly generated images after the code is added. It will not delete or modify existing image sizes.

    In any case, this won’t break your site (however, I still can’t guarantee what might happen on your site, so please make sure to test it properly before applying it to your live environment), but if parts of your theme or plugins depend on specific image sizes, those images won’t be created, which could cause layout issues or blurry visuals in rare scenarios.

    You might also want to consider using alternative solutions, such as the following plugins for managing image sizes.

    You can add two simple plugins:
    Disable Media Sizes
    Regenerate Thumbnails
    https://ww.wp.xz.cn/plugins/disable-media-sizes/
    https://ww.wp.xz.cn/plugins/regenerate-thumbnails/

    One of them is for changing all crop sizes on your website.
    Another one for deleting generated thumbnails

    Hope it helps,
    Best Regards

    • This reply was modified 12 months ago by Shahin.
    Thread Starter tonyko33

    (@toniko33)

    Hi @skalanter

    Thank you for advice.

    I have firts tried to use Disbale MediaSize, but it only consider wordpress Thumbnail. OceanThumb do not appear in the settings for deleting them. So it’s useless for what I’m trying to do.

    It would be perfect if, in time, an option could be set up directly in the theme settings to disable these formats. 😉

    Have a good day

    Shahin

    (@skalanter)

    Hello @toniko33,

    Thank you for the update.

    After disabling some media sizes, you need to regenerate all media sizes again with the second plugin. Both are working well on my end, and I saw no issue.
    These plugins meet all your needs for changing the size of the current images in the theme and all other plugins.

    Hope it helps,
    Best Regards

    Thread Starter tonyko33

    (@toniko33)

    Hello @skalanter

    I already use Regenerate Thumbnails, and when i use it, it always regenerate ocean-thumbs. That’s normal, because it takes into account all images generate by wordpress, theme and eventually plugin.

    I understand what you say. But no working. As specified in the “Disable image size” presentation :

    https://ww.wp.xz.cn/plugins/disable-media-sizes/

    And as the plugin author says “the plugin focuses on just core WordPress images/sizes”, so not disable image generated by theme or other plugin.

    No matter ! I’ve found a plugin that does the job. It takes theme images into account :

    https://ww.wp.xz.cn/plugins/disable-generate-thumbnails/

    Now, with regenerate thumbnails, it’s work perfectly.

    Have a good day !

    Hi,

    Thank you for the feedback.

    I’ve forwarded your request to our development team for review and consideration in future updates.

    We appreciate your suggestion.
    Best regards

    Thread Starter tonyko33

    (@toniko33)

    Hello @skalanter

    Thank you for your feedeback.

    I’ll take it under consideration.

    Have a good day !

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Disable OceanThumb image’ is closed to new replies.