-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Image sizes are not listed for Gallery Block. #13434
Comments
Image sizes are only shown if an image with that size actually exists. Just adding a bunch of |
It's simply not true what you're saying. Prajakta is right and the core Image block doesn't not allow you to select a custom size set with If it should, then please point us in the right direction. |
For custom image sizes to be available in the admin you need to filter 'image_size_name_choose'. Example: add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'gallery-thumb' => __( 'Gallery Thumb' ),
'medium-square' => __( 'Medium Square' )
) );
} |
@NRDay This shouldn't be necessary. I would expect all image sizes, including custom image sizes to be showing up in this dropdown list. This should be considered by default. |
@leecollings I guess the thinking is that some plugins create their own thumbnails that are not meant for use within general content and this filters gives developers the option to expose them or not. Either way, using the filter solves the issue. |
@NRDay Hmm I see your point actually, yes I agree. |
@NRDay Would one not assume that such scenarios are the exception rather than the rule? I would expect developers should need to explicitly hide them rather than explicitly show them. All of us needed to explicitly add the image sizes and found ourselves on this issue, thinking their seemingly inexplicable absence was a bug. However, if they were showing in the list in the first instance, we would be looking for a means to hide them, knowing exactly what we want rather than thinking it is broken. In other words, I imagine most people will expect their image size to be available once it is added. |
@CameronVerto I don't have any strong opinions either way to be honest. The answer to the original question is to use the filter as described. Adding custom image sizes to the admin is covered in the Perhaps there is an argument that declaring a custom image sizes' human readable name, could be done within the |
I am facing a similiar issue. I to thought that by adding custom image sizes using add_image_size() would also include them in the drop down but that is not the case. In reflection, it makes sense as there are some sizes which you may not want to have appear. In reference to previous comments, previously uploaded files will not have the new sizes and will not appear in the dropdown. If they do, it may cause an error. Rule of thumb being if you add a new image size, regenerate the thumbnails using a plugin to make sure the adjusted image sizes are applied to all images. FYI. To get it to work, I used: `// 1. Add featured image sizes add_image_size( 'medium-hard', 400, 400, true ); // 2. Register the image sizes for use in Add Media modal function child_custom_sizes( $sizes ) {
} |
Above method works for Gutenberg editor also. |
You don't have to regenerate thumbnails to see the sizes in the select box for Gutenberg/Media Editor though. You only need to regenerate thumbnails to make old images display at the new sizes if you added them. I was briefly stuck as to why image names weren't showing up in Gutenberg image block once I'd inserted the |
Closing as this has been addressed by @NRDay |
This bit me, too. Would be great if the default behaviour included custom image sizes in the popup menu. |
I'm finding that the image size select box for image blocks only shows up with images uploaded directly to the block. If I use existing images in the media library (with all those sizes available) I never see the image size chooser in the settings sidebar. |
@uniondesign Same for me. Have you found an explanation ? a fix ? thanks |
If you're able to create the new image crop with a plugin like Regenerate Thumbnails the crop will appear in the dropdown. |
@dylanjameswagner that does not work. As @davidallenlewis says, you to upload the image from the Media Library for the new size to appear in the image block. Just tested it. |
Describe the bug
Custom Image sizes are not listed for Gallery Block.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should list all image sizes including custom image sizes.
Screenshots
Image Size - http://screenshots.sharkz.in/prajakta/2019/01/2019-01-23_12-45-39.png
Default image sizes - http://screenshots.sharkz.in/prajakta/2019/01/2019-01-23_12-46-12.png
Additional context
I just tried Image block. I could not find all image sizes under image size option. I have added added custom image sizes. Only default full size, thumbnail, medium sizes listed only.
I tried using regenerate thumbnail plugin.
Is there any issue while retriving image sizes?
The text was updated successfully, but these errors were encountered: