Minimum Dimensions Requirement for Featured Image?

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”.

Leave a Comment