I am creating a baseball website with multiple Authors. From past experience, no matter how well you know someone personally, it doesn’t mean they will follow or even read your instructions.
That being said, I would like to require that any image an Author decides to “Use as featured image” be at minimum of 640px wide and a minimum of 360px tall.
I have required that each post have a Featured Image using the WyPiekacz plugin; the post will not publish without a Featured Image. I have blocked the ability for an Author to hotlink to another site by removing the “From URL” tab in Add Media using Bainternet’s code.
Now I need to require that any image used as the featured image is at least 640px by 360px. I am no means a coder, but I have been playing around with and trying to use Maor Barazany’s code as a starting point, but to no avail. His code forces minimum dimensions for any image that is uploaded.
well if you are using WyPiekacz plugin; as you said for checking that featured image is uploaded, you can tweak it little bit to check that if there is featured image it is of minimum dimesions as you required.
$has_thumbnail = false;
if ( ( $post_id > 0 ) && function_exists( 'has_post_thumbnail' ) ) {
$has_thumbnail = has_post_thumbnail( $post_id );
}
$has_thumbnail = apply_filters( 'wypiekacz_check_thumbnail', $has_thumbnail, $post_id, $post_data );
if ( !$has_thumbnail ) {
$this->errors[] = array( 'post_thumbnail', __('Post thumbnail (Featured image) is required.', 'wypiekacz') );
}
You can change above code in wypiekacz.php to,
$has_thumbnail_proper_dimension = false;
if ( ( $post_id > 0 ) && function_exists( 'has_post_thumbnail' ) ) {
$has_thumbnail = has_post_thumbnail( $post_id );
list($url, $width, $height) = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), "Full");
echo $imgsrc[0];
if($width>=640 and $height>=360){
$has_thumbnail_proper_dimension=true;
}
}
$has_thumbnail = apply_filters( 'wypiekacz_check_thumbnail', $has_thumbnail, $post_id, $post_data );
if ( !$has_thumbnail ) {
$this->errors[] = array( 'post_thumbnail', __('Post thumbnail (Featured image) is required.', 'wypiekacz') );
}
if ( !$has_thumbnail_proper_dimension ) {
$this->errors[] = array( 'post_thumbnail', __('Post thumbnail (Featured image) should be atleast 640x360.', 'wypiekacz') );
}
well i don’t understand what you mean by “Media Library Tab”.