• I have a custom script that will load up the wordpress media library and let a user select an image from this. It works, but no matter what image size is selected from the drop down, the full size image is always the “selected” image. I have checked over the object and i can see that the 4 urls for the different sizes are also returned so i have access to them, but i dont know what the value from the dropdown is. Ideally id like the size to be the “selected” url that returns, but if i can just access the value that was set in the dropdown i can make a workaround to get it working.

    Here is the code i have.

        file_frame = wp.media.frames.file_frame = wp.media({
            title: 'Select a image to upload',
            button: {
                text: 'Use this image',
            },
            frame: 'post',
            editing:true,
            multiple: false
        });
    
        file_frame.on( 'insert', function() {
            attachment = file_frame.state().get('selection').first().toJSON();
            $("#featuredimage").val(attachment.url);
            $("#featuredimagepreview").html("<img src='" + attachment.url + "' />");
            console.log(file_frame);
         });
    • This topic was modified 7 years, 3 months ago by dano1066.
  • The topic ‘Getting selected image size from media uploader’ is closed to new replies.