Skip Navigation

[Resolved] Featured image allowed upload sizes

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.29 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Shane 6 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#907524

Eso

Hi friends,

In Cred Forms, where must I go to set the allowed featured image file upload size (Kb) ?

AND also I would like to be able to set the allowed width-height dimensions (Pixel) for each specific (featured image) field...

Is it possible to achieve this ?

Thanks.

#907608

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for contacting our support forum.

Actually this is possible by using the hook below. Add it to your functions.php file


add_filter('cred_form_ajax_upload_validate','my_validation',10,2);
function my_validation($error_fields, $form_data)
{
    //field data are field values and errors
    list($fields,$errors)=$error_fields;
    //validate if specific form
    if ($form_data['id']==2991)
    {
        //check if featured image exists o
        if (isset($fields['_featured_image']))
        {
        	list($width, $height, $type, $attr) = getimagesize($fields['_featured_image']['field_data']['tmp_name']);	

        	if ($width != 1220 && $height != 360) {
        		  //set error message for featured image
            	$errors['_featured_image'] = 'Image size must be 1220 * 360, your image dimensions are '.$width.' * '.$height;
        	}
          
        }
    }
    //return result
    return array($fields,$errors);
}

Please try this and let me know if it helps. Also you need to replace the 2991 with the ID of your form.

Thanks,
Shane

#907618

Eso
mini.jpg
maxi.jpg

Hi Shane,

Unfortunatly adding the code in child folder's function.php didnt work...

To make it more clear By default the multiline box shows only 5 rows on load.
Of course you can enlarge the box with the right bottom corner. (Check mini.jpg)

But It can be really cool if the multiline box could show 12-15 rows on page load.

I have setup many questions in this field and I would like some of them at least to be visible on page load... (Check maxi.jpg)

Do you have any other suggestion ?

Thanks a lot dear friend.

E.

#907626

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,
Actually it seems that you are describing another issue in your response as my response here https://toolset.com/forums/topic/featured-image-allowed-upload-sizes/#post-907608

Was for the featured image issue.

Thanks,
Shane

#907627

Eso

Dear Shane I am sorry 😀
I have wrote back to the wrong ticket 🙂
My reply is about the multiline row numbers... If you have any suggestions for that, it will be more than welcome too.
I will try that again for the files sizes and let you know...
E.

#907630

Eso

Ok.

So here the image pixel sizes are limited to max 1220px - 360px.

What about max file size in kb ? Is it possible to set it up too?

Thanks !

#907631

Eso

Hmm...
I have tried but it didnt work because my field is not featured image but "image".
Also there's one more thing...
I would like to setup the MAX and MIN image dimensions in PX : max-min height and max-min width if possible.
If I insert this code people will have to insert the exact image size and I am not sure they all know how to resize an image :/
It musnt refuse all image files that wont be very user friendly.
MAybe it is better to setup a limit for the image file size in kb ?
If you can suggest anything I'll give it a try.
Thanks.

#908382

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Eso,

Sorry for the delay in response as our forums are closed on the weekends.

Unfortunately with this code we can only do it for the image dimensions.

For the max and min dimensions I would recommend that you contact one of our contractors as this would require some amount of custom coding to achieve.

The code that I provide was a basic solution for the file image size but more modification would be needed in order to get exactly what you want which would be out of our support scope.

Thanks,
Shane