I was asking the same question in the comments of another question.
The solution is (thanks to Кирилл-Меркушев), to get another URL from the onSelect Callback.
Before I had this:
function onSelectImage( media ) {
props.setAttributes( { mediaURL: media.url } );
props.setAttributes( { mediaID: media.id } );
}
Then I console logged the media parameter, where I could find the different size URLs, so I changed it to this for my use:
function onSelectImage( media ) {
console.log(media);
var url;
if (media.sizes.medium.url) {
url = media.sizes.medium.url;
} else if (media.sizes.thumbnail.url) {
url = media.sizes.thumbnail.url;
} else {
url = media.url;
}
props.setAttributes( { mediaURL: url } );
props.setAttributes( { mediaID: media.id } );
}
Related Posts:
- How to manage attachment relationships for specific posts in WP 3.5+
- How to trigger a refresh in the media modal
- How can I bulk delete media and attachments using WP-CLI?
- Expanding new Media Uploader in WordPress 3.5
- Uploading Multiple Attachments From Front-End With A Description
- Get all posts (of any post type) an attachment is used in
- How to single click to download image in single post
- Unattaching unlinked images
- Delete attachments from Front end
- Get attachments (get_posts) and WP 3.5 new uploader
- How to count media attachments?
- How to make a customized “Create Gallery” tab in the ‘Add Media’ window?
- How to retrieve alt attribute for an attachment (uploaded image)?
- Get the path of the first attached media (single.php)
- Show attached media image if no thumbnail image detected
- media ‘path’ issue / concern when bringing files live
- Media library quick/inline edit
- How to compress image before inserting to wordpress using wp_insert_attachment function?
- Massive photogallery import
- the_time() returning wrong date/time (way in the future)
- Media Library Mess After FTP … /uploads
- wp_delete_attachment doesn’t delete image files / doesn’t work
- Setting an image as post header (not featured image)
- Using the GetMediaLibrary() method in python-wordpress-xmlrpc.media, how to iterate over the result?
- Remove attached media
- How to use taxonomies on attachments with the new Media Library?
- Getting a taxonomy’s thumbnail url
- Check if post has attachments (not image)
- How do I detach images from posts?
- How to get attachment caption (get_the_excerpt gives parent post excerpt) ?
- How to get all files inserted (but not attached) to a post
- custom fields for attachments?
- URL rewrite with add_rewrite_rule and attachment_id
- Get attachment from post
- Add column for attachment file size
- Change image link: wp_get_attachment_link
- Multi-line captions on attachments
- Gel all image from certain post type
- ID of images from gallery
- wp_get_attachment_image_src always returns false
- Exact image sizes
- Adding attachment file name to email link
- How to allow specific extensions and file size to wp_mail attachment?
- wp_insert_post featured image from library
- Get url from file uploaded in Media Library
- attachments with tags and get_posts
- Hide “Gallery Settings” and “Insert into Post” button from Attachment window
- How can I change wordpress attachment url and protect it?
- Adding class to next/prev image link in attachment.php
- Getting ID from ajax response of async-upload.php
- How to add multiple checkbox elements to media attachments?
- Get attachment next and previous by author only
- Edit default image attachment size
- Perform a custom (bulk) action in media view
- Strip the folder path away from wp_get_attachment_url to show filename only
- Need to get array of images ID attached to post
- How to fetch only media that was already attached to a post/page?
- How to set a conditional statement for $attachment->post_excerpt, to check for value?
- Attach media to multiple posts
- wp_mail not sending attachment
- How to check if there is image title, caption, description?
- Password protect media attachment – share across guests
- Display random gallery images and its parent post title leading to parent post permalink
- Don’t show attachments if they are inserted in post
- How to remove attachments size attribute [duplicate]
- Handling image uploads without thickbox
- How to extend an existing (Gutenberg) block
- How do I get all attachments that are used in the current post, not just the children?
- Is there a move_attachment_file() function in wordpress?
- Auto create file and send it via wp_mail()
- Create page from post attachments
- how to get random media id from media gallery
- Attach pdf from dynamic url
- How to get $attachment->ID in custom functions
- All attachment pages give 404
- Get Attachment Image Class by attachment id
- Automatically deactivate link for attachments
- Hiding or removing file extension displayed in HTML on attachment page
- After changing permalink structure, How to redirect attachment url to old parent post url
- Getting attachment post using wp_get_attachment_link
- wp_mail Allow Remote Attachments from CDN
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- How to identify and delete all the images/pdf’s which are not assigned to any post/custom-post/page and also which are repeated
- Filter not applied to all image sizes
- Zip a file and add as attachment
- Nothing found in uploads folder after wp_insert_attachment
- Remove post with attachments hook
- PHPMailer – Uploading a file
- How to restrict users to only access their own media files in wordpress
- wp_mail doen’t send mails whit attachment
- Check if author or uploader id of the attachment(uploaded) image is match?
- When inserting attachments into a blog post, how can I get WordPress to use the full filename with the extension?
- List attachments of a page
- Is there a way to add Reattach and Unattach links in image gallery?
- Post images not displaying as attachments
- Showing the attachment for a page?
- Gallery Thumbnail Layout Template
- How can I attach files without using a plugin?
- Custom Fields, Media uploader, Attachments
- Media library upload hook