Created
September 26, 2013 10:56
-
-
Save PhilippSchreiber/6712643 to your computer and use it in GitHub Desktop.
Modify the image URL used in Wordpress Media Frame.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ps_wp_prepare_attachment_for_js($response, $attachment, $meta) { | |
if($response['type'] == 'image') { | |
$image_src = wp_get_attachment_image_src( $response['id'], 'thumbnail' ); //Use any image size added to your wordpress installation | |
if( is_array($image_src) ) { | |
$response['url'] = $image_src[0]; | |
} | |
} | |
return $response; | |
} | |
add_filter( 'wp_prepare_attachment_for_js', 'ps_wp_prepare_attachment_for_js', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you rock - was trying to get this same thing working for almost an hour before finding this. epic.