I'm using the following code to open the WordPress media uploader in my plugin. The code works fine and returns the selected image.
/* media*/
var mediaUploader;
$('#upload_image_button').click(function(e) {
e.preventDefault();
if (mediaUploader) {
mediaUploader.open();
return;
}
mediaUploader = wp.media.frames.file_frame = wp.media({
title: 'Select Image',
button: {
text: 'Select Image'
}, multiple: false });
mediaUploader.on('select', function() {
var attachment = mediaUploader.state().get('selection').first().toJSON();
$('#background_image').val(attachment.url);
console.log(attachment.sizes);
});
mediaUploader.open();
});
However when I look at the console - the custom image sizes (height and width) in the attachment.sizes are wrong, but the image, e.g. An image of 1024 x 1024 reports as 580x580 - but the filename clearly shows 1024x1024.
Any ideas on why this would be the case?
edit: Here is an image of all of the Image sizes in WordPress including 1 from the theme and one I added as a test.
As you can see the thumbnail , medium and full sizes are correct but large and the 2 added (using add_image_size( 'imagetest', 1200, 630, true ); // Hard Crop Mode) Are incorrect.
Thanks in advance.

