Is there any way in WordPress to prevent content editors from selecting the “Full size” option when uploading images to a post? I’d like them to just have the “thumbnail”, “medium”, and “large” options. I used to use the Scissors plugin to do this, but as of WordPress 2.9 this plugin no longer works.
Share
You could acheive this result by forcing WordPress not to display the full size option. The function that creates the size radio buttons is in
wp-admin/includes/media.phpand is calledimage_size_input_fields.There’s no filter or action hook for that function that I’m aware of, but the function that calls it (
image_attachment_fields_to_edit) has a filter hook ofattachment_fields_to_edit.So basically we can use the filter hook to override those two functions with our own, which will only be very slightly modified.
This will work in the standard functions.php file, or I suppose you could incorporate it into a plugin.
First, add the new filter:
Next we create our two functions. I’ve just prefixed the names with
MY_for this case:The only thing that’s changed here from the normal WordPress function is that we’re calling
MY_image_size_input_fieldsinstead ofimage_size_input_fields.Now the function that does the actual hiding:
In this last function only two things change. At the top we get rid of the reference to ‘Full Size’ in the $size_names array definition. Then the line that says
$enabled = ( $downsize[3] || 'large' == $size );, we changed. We simply replaced'full' == $sizewith'large' == $size.Here’s a screenshot of the result:
