• Hi

    my wordpress attachment display settings not showing
    I have a custom theme and in my functions file, I created new image sizes but when I upload a new image in wordpress, I am unable to choose my image size from a list?!

    here is what I added to my functions.php

    if ( function_exists( 'add_image_size' ) ) {
        add_image_size('header-slider', 1280, 500, TRUE); // header Slider
        add_image_size('welcome-image', 790, 9999, TRUE); //210 pixels wide (and unlimited height)
        add_image_size('category-block', 600, 524, TRUE); // category block
        add_image_size('gallery-thumb', 368, 368, TRUE); // gallery thumb
    }
    /* Display Custom Image Sizes */
    add_filter('image_size_names_choose','wpshout_custom_sizes');
    function wpshout_custom_sizes($sizes){
        return array_merge($sizes, array(
            'header-slider' => __('Header'),
            'welcome-image' => __('Welcome'),
            'category-block' => __('Category'),
            'gallery-thumb' => __('Gallery'),
    ));
    }
    • This topic was modified 4 years, 8 months ago by jmbiddulph.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator bcworkz

    (@bcworkz)

    Your code works on my site (in both classic and block editors), so the problem lies elsewhere. Try flushing your browser cache. If that doesn’t help, try deactivating all plugins.

    TBH I only added the gallery size and I added your code to a plugin I previously wrote, not my theme. This would not make any difference in functionality.

    Thread Starter jmbiddulph

    (@jmbiddulph)

    removed cache and deactivated all plugins, still not working, I see a lot of people have this issue

    Moderator bcworkz

    (@bcworkz)

    There could be a conflict with your theme. Try temporarily adding your code to twentytwenty and testing with that theme active.

    I’m seeing the same issue. No image size selector at all. Not even the default wordpress sizes are not showing. No dropdown at all. And the sizes DO exist (i.e. the uploaded image was big enough to create the crops). I’m 100% convinced this is a WordPress bug because the Image block won’t show the image size selector even with a clean install with NO plugins and the TwentyTwenty theme. So 100% zero custom code.

    • This reply was modified 4 years, 8 months ago by takeok.
    • This reply was modified 4 years, 8 months ago by takeok.

    Appears to be server related. I have the same exact code and data on a local server and on a remote server. The image size selector for Image blocks works on the remote server but not on my local.

    OMFG. Solved it. If you add an image to an Image Block from the Media Library the Image Size option doesn’t show. It ONLY shows for images uploaded DIRECTLY to the page. Insane. I just bashed my head against a wall for over an hour on this. That seems like a bug to me. Why shouldn’t you be able to choose a crop with images added to Image Blocks from the Media Library? Doesn’t make sense to me.

    Moderator bcworkz

    (@bcworkz)

    takeok – I’m unable to replicate your experience. As noted previously, I added just the gallery size using the OP’s code. The size appears in block image settings whether image was existing in the media library or newly uploaded from within the block UI. However, when selecting from media library, the image must have been uploaded since the image size code was added. The appropriate image size does not normally exist for older images. You need a plugin that refreshes image sizes to bring older images up to date with currently registered sizes.

    Thanks. Yah. Image Size selector never works for me with images uploaded to the Media Library. It only shows up for images uploaded directly to the block.

    • Custom image size code was in place when image were uploaded to Media Library
    • Uploaded image was higher res than any of the custom sizes (so all sizes were generated)
    • Regenerated all thumbnails on the site just to be sure
    • Default WordPress images sizes don’t show up either by the way (Thumb, Medium, Large). The entire Image Size dropdown just doesn’t render
    • Virgin install of WordPress w/ TwentyTwenty and no plugins
    • Running on Local by Flywheel (Nginx + PHP 7.3.x)
    • Tested in latest Chrome and Safari on Mac
    • No ad-blockers
    • No matter what I do the image size selector doesn’t show up with images from the Media Library. SOOOO weird. Can’t figure out what’s going. It seems like some kind of WordPress bug to me but I dunno. Very odd. I’m not seeing any errors in the browser inspector / console.

    Ok I ASSUMED (always a mistake) the image sizes were being generated because a) the uploaded images were plenty big enough to generate the smaller crops and b) I used a plugin to force re-generate all image sizes… but when I looked in the actual uploads folder I found that in fact, no images sizes are being generated at all. Not even the WordPress default sizes. Perhaps a missing PHP module or something? Anyway that has to the problem in my case. At least I know what so investigate now. Thanks for your input. Sorry for spamming this thread.

    Can confirm that on a new WP install done via the latest version of Local by Flywheel (5.6.6) neither Imagick or GD PHP extensions are installed. So that’s what my problem was.

    Moderator bcworkz

    (@bcworkz)

    If that’s the default configuration of LbF, that’s not good. While an image library is only “recommended” for WP, GD or Imagick is really required to meet minimum user expectations. I’d say this is something LbF should address if there is neither by default. Thanks for letting us know what your findings were.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Custom Image Size not showing’ is closed to new replies.