Last active
September 20, 2017 10:27
-
-
Save HelloAlberuni/b89f827b86331ae3f4a163d5419167b0 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
//register field | |
array( | |
'type' => 'text', | |
'label' => __( 'Image Size', 'uniqlo' ), | |
'name' => 'image_size', | |
'value' => '570x290-crop', | |
'description' => __(' Set the image size: "full", "thumbnail", "medium", "large", "390x450-crop" or ex:500x250', 'uniqlo'), | |
), | |
// custom image size | |
$size_array = array('full', 'medium', 'large', 'thumbnail','570x290-crop'); | |
$data_image = ''; | |
if( in_array( $image_size, $size_array ) ){ | |
$data_image = wp_get_attachment_image( $image_id, $image_size); | |
}else{ | |
$img_full = wp_get_attachment_image_src( $image_id, 'full' )[0]; | |
$custom_img_url = kc_tools::createImageSize( $img_full, $image_size ); | |
$img_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true); | |
$data_image = '<img src="'.$custom_img_url.'" alt="'.$img_alt.'" >'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment