Fix: Only show available image sizes #19301
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, we are always showing the image size picker with all available sizes on the gallery and image block even if a size (or no size at all) is available. This means that on images inserted by URL, where it is not possible to choose a size we were still showing a size picker even though it does nothing.
This PR updates the computation of the available sizes to take into account what sizes are in fact available for the image, or available for some image on the image block.
How has this been tested?
I inserted an image by URL.
I verified the option to choose an image size was not available.
I inserted an image using the media library. I verified the option to choose an image size was available.
I transformed the image inserted by URL into a gallery.
I verified the option to choose an image size was not available in the gallery.
I converted the gallery block back to an image. I multi-selected both image blocks (the one inserted by URL and the one inserted from the media library) and transformed the blocks into a gallery.
I verified the option to choose an image size was available in the gallery.