• Hi Team !

    I contacted you about 6 months ago because of unwanted miniatures despite the size annihilation : https://wordpress.org/support/topic/latest-version-adds-new-thumbnails/

    You suggested this code to me, and it worked perfectly:

    function remove_extra_image_sizes() {
    foreach ( get_intermediate_image_sizes() as $size ) {
    if ( in_array( $size, array( ‘ocean-thumb-m’, ‘ocean-thumb-ml’, ‘ocean-thumb-l’ ) ) ) {
    remove_image_size( $size );
    }
    }
    }
    add_action(‘init’, ‘remove_extra_image_sizes’);

    But since a few weeks, it’s starting again (I didn’t look at which update of oceanWP) and it systematically creates -100×100.ext thumbnails without me touching anything in the child theme.

    Please, could you tell me how to remove this unwanted thumbnails.

    Thank you very much ♥
    Thomas

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello @thomhsb,
    Thank you for reaching out,

    You can use a third-party plugin to manage all thumbnails on your website. For example, you can use this plugin:
    https://wordpress.org/plugins/disable-media-sizes/

    Or, this one: https://wordpress.org/plugins/disable-generate-thumbnails/; Also, If you are interested in removing them, this plugin will help you.

    Please note that before changing any settings of those plugins, please get a full backup from your website(just in case).

    Best Regards

    Thread Starter Thomas

    (@thomhsb)

    Hello @skalanter,

    I never needed a plugin for this… did you see the previous discussion please?
    https://wordpress.org/support/topic/latest-version-adds-new-thumbnails/

    As explained in the previous thread, I myself annihilate the creation of thumbnails via the functions.php file in my child theme, example:

    unset($sizes[‘thumbnail’]);
    unset($sizes[‘medium’]);
    unset($sizes[‘medium_large’]);
    unset($sizes[‘large’]);
    unset($sizes[‘woocommerce_thumbnail’]);
    unset($sizes[‘woocommerce_gallery_thumbnail’]);
    unset($sizes[‘woocommerce_single’]);
    Etc…

    And it worked fine before version 3. As of version 3, the thumbnails still reappeared and I reported it. You then gave me this :

    function remove_extra_image_sizes() {
    foreach (get_intermediate_image_sizes() as $size){
    if (in_array( $size, array(‘ocean-thumb-m’, ‘ocean-thumb-ml’, ‘ocean-thumb-l’))) { remove_image_size( $size );
    }}}
    add_action(‘init’, ‘remove_extra_image_sizes’);

    Even though I didn’t understand why this was necessary, it worked. But since the last version, the 100×100 thumbnails have reappeared, and without me touching anything.

    Finally, I tried to add this to your code: “ocean-thumb”.

    This gives :

    function remove_thunbails_sizes() {
    foreach (get_intermediate_image_sizes() as $size){
    if(in_array( $size, array(‘ocean-thumb‘, ‘ocean-thumb-m’, ‘ocean-thumb-ml’, ‘ocean-thumb-l’))) { remove_image_size( $size ); }
    }}
    add_action(‘init’, ‘remove_thunbails_sizes’);

    And there, perfect, no more 100×100 thumbnails.

    But it’s not normal to have to add this when the thumbnail removal function is effective in functions.php. Why does your theme refuse to take into account the WordPress original functions?

    The code below works perfectly elsewhere, under all themes, without any specific addition:

    add_filter(‘intermediate_image_sizes_advanced’, function($sizes){
    unset($sizes[‘thumbnail’]);
    unset($sizes[‘medium’]);
    unset($sizes[‘medium_large’]);
    unset($sizes[‘large’]);
    unset($sizes[‘shop_catalog’]);
    unset($sizes[‘shop_single’]);
    unset($sizes[‘shop_single_small_thumbnail’]);
    unset($sizes[‘shop_thumbnail’]);
    unset($sizes[‘woocommerce_thumbnail’]);
    unset($sizes[‘woocommerce_gallery_thumbnail’]);
    unset($sizes[‘woocommerce_single’]);
    unset($sizes[‘1536×1536’]);
    unset($sizes[‘2048×2048’]);
    unset($sizes[‘blog-isotope’]);
    unset($sizes[‘product_small_thumbnail’]);
    return $sizes; });

    Since OceanWP v3, I have to add your hook to stop thumbnails creation.
    Why ?

    Hello @thomhsb,

    Thank you for your feedback.

    I fully checked the theme and couldn’t find any -100×100 thumbnail generated files.

    Perhaps some plugins updated and added those sizes, or maybe you’ve set that size on the customizer(or other settings). Since WooCommerce(from version 6.8) updated some actions, we released a compatibility version for those changes. So for troubleshooting, please check the settings on the customizer or check the settings of all plugins you have(https://github.com/woocommerce/woocommerce/pull/33772).

    Please check the changelogs in the following links:
    https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/changelog.txt
    https://docs.oceanwp.org/article/653-oceanwp-theme-changelog

    The previous topic’s solution is still correct because it is in WordPress. For more information about that function, please follow this link: https://developer.wordpress.org/reference/functions/remove_image_size/. Please try it and check it on a fresh installation.

    But those plugins(previous reply) do precisely the thing that you need.
    Otherwise, you should check the code on the theme or plugins to find or troubleshoot your code.

    However, if you want to update it without using any plugin, you should search on the theme and plugins codes to find the new images sizes(if it was added as a new feature – but in the theme, we didn’t add a new size for images – perhaps other plugins you have added). Here is an example of that function: https://developer.wordpress.org/reference/functions/remove_image_size/#comment-1569.

    About this part:

    But it’s not normal to have to add this when the thumbnail removal function is effective in functions.php. Why does your theme refuse to take into account the WordPress original functions?

    We’ve some options on the customizer > woocommerce > product images that make a new size for thumbnails.
    Please check this screenshot: https://postimg.cc/Bt0KZc7N.

    If you want to disable them or change them, the solution is customization. In this case, to customize the theme, please follow the steps below:

    By using FTP or cPanel access (if you didn’t use the localhost), Go to this directory:
    wp-content\themes\oceanwp\partials
    Find your template which you want to customize and copy that template file(in your case, for example, you need to change the date on the blog pages, so you need to use the blog template(s): https://i.postimg.cc/brv9gn9s/image.png).

    Then head over to the same path on the child theme. There isn’t an entry folder as a default on your child theme, so you need to create a new one(one time).

    Example: If you want to change the HTML tags structure in the single blog posts featured image for standard post format, all you need in this step is:

    1. Head over to your WP root > wp-content > themes > oceanwp > partials> single > media path.
    2. Then, find the “blog-single.php” file and copy this file.
    3. After that, back to the themes folder (wp root > wp-content > themes) and go to oceanwp-child-theme-master folder.
    4. Create a new folder into the child theme with the “partials” name.
    5. Go to the /partials/ folder and create a new folder with the “single” name.
    6. Go to the /single/ folder and create a new folder with the “media” name.
    7. Go to the /media/ folder and paste the “blog-single.php” file here.

    * Please check this screenshot: https://i.postimg.cc/sxjYTWyt/image.png.
    * Download child theme: https://docs.oceanwp.org/article/90-sample-child-theme

    Note: It’s working with the /woocommerce/ folder or root of the theme files.

    I hope that helps.
    Best Regards

    • This reply was modified 1 year, 5 months ago by Shahin.
    Thread Starter Thomas

    (@thomhsb)

    Hello @skalanter,

    Thank you very much for all these explanations. I will try to look this weekend at what you propose but one thing is sure:

    1/ Having checked everything at the time, I promise that I don’t have any other plugin that defines a 100×100 size. Not even me, on the contrary.

    2/ I set the Thumbnail Width part to zero. Just like in the WordPress settings, the sizes are zero. Please, see this screenshot: https://postimg.cc/1fB11r82

    As I said before, in my functions.php :

    add_filter(‘intermediate_image_sizes_advanced’, function($sizes){
    unset($sizes[‘thumbnail’]);
    unset($sizes[‘medium’]);
    unset($sizes[‘medium_large’]);
    unset($sizes[‘large’]);
    unset($sizes[‘shop_catalog’]);
    unset($sizes[‘shop_single’]);
    unset($sizes[‘shop_single_small_thumbnail’]);
    unset($sizes[‘shop_thumbnail’]);
    unset($sizes[‘woocommerce_thumbnail’]);
    unset($sizes[‘woocommerce_gallery_thumbnail’]);
    unset($sizes[‘woocommerce_single’]);
    unset($sizes[‘1536×1536’]);
    unset($sizes[‘2048×2048’]);
    unset($sizes[‘blog-isotope’]);
    unset($sizes[‘product_small_thumbnail’]);
    return $sizes; });

    If I test all this with another theme, no thumbnails.
    If I put OceanWp back in, the thumbnails still appear.

    So I have to add this to make them disappear again:

    function remove_extra_image_sizes() {
    foreach (get_intermediate_image_sizes() as $size){
    if (in_array( $size, array(‘ocean-thumb-m’, ‘ocean-thumb-ml’, ‘ocean-thumb-l’))) { remove_image_size( $size );
    }}}
    add_action(‘init’, ‘remove_extra_image_sizes’);

    Anyway, I’ll test various things but it’s pretty mathematical in the end, because if another plugin added the 100×100 size, the other themes would be forced to do it too.

    I’ll come back to you if I find something else…
    Thanks anyway, I really appreciate your availability 😉

    Thread Starter Thomas

    (@thomhsb)

    Oups…

    A mistake on my part when copying and pasting : To be logical with my WordPress and OceanWp configuration (https://postimg.cc/1fB11r82), I have of course reactivated the two “medium” thumbnails.

    add_filter(‘intermediate_image_sizes_advanced’, function($sizes){
    unset($sizes[‘thumbnail’]);
    // unset($sizes[‘medium’]);
    unset($sizes[‘medium_large’]);
    unset($sizes[‘large’]);
    unset($sizes[‘shop_catalog’]);
    unset($sizes[‘shop_single’]);
    unset($sizes[‘shop_single_small_thumbnail’]);
    unset($sizes[‘shop_thumbnail’]);
    unset($sizes[‘woocommerce_thumbnail’]);
    unset($sizes[‘woocommerce_gallery_thumbnail’]);
    // unset($sizes[‘woocommerce_single’]);
    unset($sizes[‘1536×1536’]);
    unset($sizes[‘2048×2048’]);
    unset($sizes[‘blog-isotope’]);
    unset($sizes[‘product_small_thumbnail’]);
    return $sizes; });

    Normally, when I insert an image, it keeps the original image and makes a single 388xratio thumbnail.

    That’s all I want actually; the original image and the 388x— medium thumbnail.

    Anyway, I’ll let you know if I find anything but for now, it’s working again with the hook.

    • This reply was modified 1 year, 5 months ago by Thomas.

    You’re welcome. I’m glad we could help.
    Should you have any further questions, please let us know.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Added unwanted thumbnails #2’ is closed to new replies.