TOPIC:

Resize image options in Wordpress 7 months 2 weeks ago #272564

  • Topic Author
  • webciudadreal
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 80
  • Thanks: 1
Finally I've solved this in my own. I have created a php function in order to resize image files and it's ok.

Thanks

Please Log in or Create an account to join the conversation.

Resize image options in Wordpress 7 months 2 weeks ago #272569

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 3265
  • Karma: 2
  • Thanks: 160
Hi,

super, I'm glad you solve it!

Could you please provide here the function, so that other users can do the same things!

Thanks! :)

Regards,
Mirko

Please Log in or Create an account to join the conversation.

Resize image options in Wordpress 7 months 2 weeks ago #272602

  • Topic Author
  • webciudadreal
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 80
  • Thanks: 1
I've used this as "base" function:

stackoverflow.com/questions/13596794/res...pg/13596913#13596913
function resize($newWidth, $targetFile, $originalFile) {

    $info = getimagesize($originalFile);
    $mime = $info['mime'];

    switch ($mime) {
            case 'image/jpeg':
                    $image_create_func = 'imagecreatefromjpeg';
                    $image_save_func = 'imagejpeg';
                    $new_image_ext = 'jpg';
                    break;

            case 'image/png':
                    $image_create_func = 'imagecreatefrompng';
                    $image_save_func = 'imagepng';
                    $new_image_ext = 'png';
                    break;

            case 'image/gif':
                    $image_create_func = 'imagecreatefromgif';
                    $image_save_func = 'imagegif';
                    $new_image_ext = 'gif';
                    break;

            default: 
                    throw new Exception('Unknown image type.');
    }

    $img = $image_create_func($originalFile);
    list($width, $height) = getimagesize($originalFile);

    $newHeight = ($height / $width) * $newWidth;
    $tmp = imagecreatetruecolor($newWidth, $newHeight);
    imagecopyresampled($tmp, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);

    if (file_exists($targetFile)) {
            unlink($targetFile);
    }
    $image_save_func($tmp, "$targetFile.$new_image_ext");
}

Function defined in Submit Pieces / Begin Submit / Custom

In End Submit / Custom, I've used:
$file_field=ff_getSubmit('field_name');
resize(1000,$file_field,$target_file);
The following user(s) said Thank You: Mirec

Please Log in or Create an account to join the conversation.

Resize image options in Wordpress 7 months 2 weeks ago #272604

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 3265
  • Karma: 2
  • Thanks: 160
Hi webciudadreal,

Thank you very much for sharing this helpful solution which will help most of the users!

Have a nice day! :)

Regards,
Mirko

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.064 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!