Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › How could i limit store vendor only upload 600 x 600 px image at product?
- This topic has 18 replies, 2 voices, and was last updated 5 years, 11 months ago by WCFM Forum.
- AuthorPosts
- December 16, 2018 at 6:09 am #40191
- December 20, 2018 at 12:16 pm #40473WCFM ForumMember
HI,
You should more concern about actual product page image display.
How that looks?
Thank You
- December 20, 2018 at 12:18 pm #40474MOHOParticipant
If the user upload not square image, it will not good look at frontend.
- December 20, 2018 at 1:30 pm #40485WCFM ForumMember
Umm .. normally themes comes with function to adjust images as per product template.
Is this not happening in your site?
Can you please ask theme author once regarding this?
Thank You
- December 20, 2018 at 5:20 pm #40501WCFM ForumMember
Hi,
You may use this code for the purpose ->
function wcfm_max_image_size( $file ) { $img = getimagesize($file['tmp_name']); $minimum = array('width' => '600', 'height' => '600'); $width = $img[0]; $height = $img[1]; if ($width > $minimum['width'] ) return array("error"=>"Image dimensions are too large. Maximum width is {$minimum['width']}px. Uploaded image width is $width px"); elseif ($width < $minimum['width'] ) return array("error"=>"Image dimensions are too small. Minimum width is {$minimum['width']}px. Uploaded image width is $width px"); elseif ($height > $minimum['height']) return array("error"=>"Image dimensions are too large. Maximum height is {$minimum['height']}px. Uploaded image height is $height px"); elseif ($height < $minimum['height']) return array("error"=>"Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image height is $height px"); else return $file; return $file; } add_filter( 'wp_handle_upload_prefilter', 'wcfm_max_image_size' );
Thank You
- December 23, 2018 at 10:27 pm #40824MOHOParticipant
great i see
Image dimensions are too large. Maximum width is 600px. Uploaded image width is 1200 px
Image dimensions are too small. Minimum width is 600px. Uploaded image width is 300 px
————-
Minimum width 600px
Maximum width 1200pxcould you yell me how to change it, thanks
- December 24, 2018 at 6:19 am #40883WCFM ForumMember
Hi,
Please use this revised code –
function wcfm_max_image_size( $file ) { $img = getimagesize($file['tmp_name']); $minimum = array( 'min_width' => '600', 'max_width' => '1200', 'height' => '600'); $width = $img[0]; $height = $img[1]; if ($width > $minimum['max_width'] ) return array("error"=>"Image dimensions are too large. Maximum width is {$minimum['max_width']}px. Uploaded image width is $width px"); elseif ($width < $minimum['min_width'] ) return array("error"=>"Image dimensions are too small. Minimum width is {$minimum['min_width']}px. Uploaded image width is $width px"); elseif ($height > $minimum['height']) return array("error"=>"Image dimensions are too large. Maximum height is {$minimum['height']}px. Uploaded image height is $height px"); elseif ($height < $minimum['height']) return array("error"=>"Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image height is $height px"); else return $file; return $file; } add_filter( 'wp_handle_upload_prefilter', 'wcfm_max_image_size' );
Thank You
- December 26, 2018 at 4:42 am #41140MOHOParticipant
could i add ‘max_height’ => ‘1200’ ??
Minimum height 600px
Maximum height 1200px - December 26, 2018 at 5:16 am #41144WCFM ForumMember
HI,
Sure, please use this revised code –
function wcfm_max_image_size( $file ) { $img = getimagesize($file['tmp_name']); $minimum = array( 'min_width' => '600', 'max_width' => '1200', 'height' => '600', 'max_height' => '1200' ); $width = $img[0]; $height = $img[1]; if ($width > $minimum['max_width'] ) return array("error"=>"Image dimensions are too large. Maximum width is {$minimum['max_width']}px. Uploaded image width is $width px"); elseif ($width < $minimum['min_width'] ) return array("error"=>"Image dimensions are too small. Minimum width is {$minimum['min_width']}px. Uploaded image width is $width px"); elseif ($height > $minimum['max_height']) return array("error"=>"Image dimensions are too large. Maximum height is {$minimum['max_height']}px. Uploaded image height is $height px"); elseif ($height < $minimum['height']) return array("error"=>"Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image height is $height px"); else return $file; return $file; } add_filter( 'wp_handle_upload_prefilter', 'wcfm_max_image_size' );
Thank You
- December 27, 2018 at 3:17 am #41285MOHOParticipant
I didn’t know why it not work for your new code
http://mall.sites.moho.tw/admin/products-manage/ - December 27, 2018 at 7:23 am #41316WCFM ForumMember
Hi,
None of these conditions are working for you?
Thank You
- December 27, 2018 at 7:34 am #41318MOHOParticipant
the last one code not work, i will try again
- December 27, 2018 at 8:12 am #41324WCFM ForumMember
Strange! Code is perfect.
Hope you are uploading an image which has height more than 1200?
Can you send me that image?
Thank You
- December 27, 2018 at 9:14 am #41328
- December 27, 2018 at 9:30 am #41331WCFM ForumMember
Hi,
Conditions are checking one by one.
And this image restricted by it’s large width – https://ibb.co/PMkkNgL
Height checking not executed.Thank You
- December 27, 2018 at 11:32 pm #41459MOHOParticipant
i see it work, thanks.
and could change this?
“height –> min_height”
It will be good for manage, thanks.
- December 28, 2018 at 5:52 am #41464WCFM ForumMember
Hi,
“height –> min_height”
– What change? Height check before max-height check?
Thank You
- December 28, 2018 at 6:58 am #41473
- December 28, 2018 at 12:06 pm #41522WCFM ForumMember
OK, understand.
Here is modified code –
function wcfm_max_image_size( $file ) { $img = getimagesize($file['tmp_name']); $minimum = array( 'min_width' => '600', 'max_width' => '1200', 'min_height' => '600', 'max_height' => '1200' ); $width = $img[0]; $height = $img[1]; if ($width > $minimum['max_width'] ) return array("error"=>"Image dimensions are too large. Maximum width is {$minimum['max_width']}px. Uploaded image width is $width px"); elseif ($width < $minimum['min_width'] ) return array("error"=>"Image dimensions are too small. Minimum width is {$minimum['min_width']}px. Uploaded image width is $width px"); elseif ($height > $minimum['max_height']) return array("error"=>"Image dimensions are too large. Maximum height is {$minimum['max_height']}px. Uploaded image height is $height px"); elseif ($height < $minimum['min_height']) return array("error"=>"Image dimensions are too small. Minimum height is {$minimum['min_height']}px. Uploaded image height is $height px"); else return $file; return $file; } add_filter( 'wp_handle_upload_prefilter', 'wcfm_max_image_size' );
Thank You
- AuthorPosts
- The topic ‘How could i limit store vendor only upload 600 x 600 px image at product?’ is closed to new replies.