Last active
June 15, 2021 06:26
-
-
Save kriskhoury/ab9afda80657480f9261983eb91c9855 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
add_filter('acf/validate_value/name=validate_this_image', 'my_acf_validate_value', 10, 4); | |
function my_acf_validate_value( $valid, $value, $field, $input ){ | |
// bail early if value is already invalid | |
if( !$valid ) { | |
return $valid; | |
} | |
// load image data | |
$data = wp_get_attachment_image_src( $value, 'full' ); | |
$width = $data[1]; | |
$height = $data[2]; | |
if( $width < 960 ) { | |
$valid = 'Image must be at least 960px wide'; | |
} | |
// return | |
return $valid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment