update attachment metadata with new dimensions after image_resize_dimenstion
-
I am trying to set “width” / “height” in the function add_image_size() using the filter image_resize_dimensions which is working good so far but I have no idea how to update image attributes (new size and height ) after the resize
Here is my code:
add_action( 'after_setup_theme', 'set_custom_image_size', 20 ); function set_custom_image_size() { add_image_size( 'normal', 101, 102 ); } add_filter( 'image_resize_dimensions', 'normal_image_resize_dimensions', 11, 6 ); function normal_image_resize_dimensions( $payload, $orig_w, $orig_h, $dest_w, $dest_h, $crop ){ if( $dest_w === 101 ){ //if normal image size $width = $orig_w / 2; $height = $orig_h / 2; return array( 0, 0, 0, 0, $width, $height, $orig_w, $orig_h ); } else { //do not use the filter return $payload; } }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘update attachment metadata with new dimensions after image_resize_dimenstion’ is closed to new replies.