-
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
Add custom image sizes to the MediaUpload #7483
Comments
@dseidl Can you share more detail on what you're trying to do and how you're extending the |
@danielbachhuber sure, sorry for the limited information. Basically i have a normal MediaUpload Component in my block. <MediaUpload
onSelect={ mediaChanged }
type="image"
value=""
render={ ( { open } ) => (
<Button onClick={ open } className="towa-button button button-large">
<Dashicon icon="format-image" /> { __( 'Upload Image' ) }
</Button>
) }
/> I have also added a new custom image size via In the As a workaround i added that: (but thats just a workaround, of course it would be better if the custom image sizes are returned in the onSelect event): const mediaChanged = (image) => {
wpAPI.media().id( image.id )
.then((response) => {
const image = transformImage(response);
setAttributes({image});
});
}; The Rest API does return the custom image sizes, so i just transform the returned json so i only save the needed data (title, alt, url and the complete sizes object): const transformImage = (image) => {
return {
id: image.id,
alt: image.alt_text,
url: image.source_url,
sizes: image.media_details.sizes,
}
}; |
Cool, #7605 will do the trick for you. |
Like described in #7605 (comment), one needs to use the |
I need access to the custom image sizes url's from the MediaUpload component. Even after registration of those only full and thumbnail is returned.
Include all image sizes, like ACF did or like the /media api call does.
The text was updated successfully, but these errors were encountered: