1. i am not sure what do you mean.
2. in the Limit File Uploads snippet there are various validators some apply to individual images like the image size and dimensions and some apply to all of the like min and max files uploaded.
3. enter 500kb there
Thread Starter
bdd
(@bws-online)
I used the snippet like this:
function limit_file_uploads( $form ) {
if( $form['name'] != "advert" ) {
return $form;
}
foreach( $form["field"] as $key => $field ) {
if( $field["name"] != "gallery" ) {
continue;
}
$form["field"][$key]["validator"] = array();
// Set minimum and maximum file upload size.
// Note. this is a limit for an individual file, not whole gallery field.
$form["field"][$key]["validator"][] = array(
"name" => "upload_size",
"params" => array(
"min" => null, // minimum file size
"max" => "200KB" // maximum file size
)
);
}
return $form;
}
I added an image on an ad that was 5.70MB — it allowed that. When I view the image in the ad itself, it shows an image with an intrinsic size of 5312×2988 pixels at 878×494 pixels. If I look in the Media Library, there’s an image with that intrinsic size that’s 6MB. It did not stick to my 200KB max as in the snippet.
NOTE: There are 2 other images there, too, even though I removed them from the ad before publishing. Shouldn’t it delete images that weren’t used in the final ad? Can that be revised so it happens?
Thread Starter
bdd
(@bws-online)
Making progress!!
I cleaned up some revisions and went back to the original Limit File Uploads snippet from GitHub — all good regarding the max limit getting followed.
Do you want a new ticket regarding the NOTE on the last post?
If you removed the images in the [adverts_add] went to the preview and published the Ad then the images should not be there in the published Ad.
Maybe there was some kind of error when deleting the images due to customizations being made in the file upload, can you replicate this problem?
Thread Starter
bdd
(@bws-online)
They weren’t in the published ad, but they WERE in the Media Library. I did more testing now, though — it’s fine. Thanks.
-
This reply was modified 6 years, 11 months ago by
bdd.