• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Resize images on upload, joomla 2.5

Resize images on upload, joomla 2.5 11 years 9 months ago #24240

Hello, have to say it's a nice RSforms is a nice plugin however... I find it hard to make images resize on upload.

I've written a function in PHP that will take all $_POST images submitted, and resize them proportionally but it does not work.

I tried calling function in: silent post to url, $thankyoumessage, $post data but it won't work.

Any suggestions? I need this done asap, thank you.
The administrator has disabled public write access.

Resize images on upload, joomla 2.5 11 years 9 months ago #24246

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

The files are not stored in the $_POST variable, you will have to control them from the $_FILES variable. It's content can be viewed by adding the following code in the "Scripts called on form process" area (backend > Components > RSForm!Pro > Manage Forms > your form > Properties > PHP Scripts) and by submitting the form:

var_dump($_FILES);
die();

More information on the RSForm!Pro specialized scripting areas can be found here:

www.rsjoomla.com/support/documentation/v...602-php-scripts.html
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.
The following user(s) said Thank You: arleitiss

Resize images on upload, joomla 2.5 11 years 9 months ago #24249

Sorry, yeah I meant I wrote script that processes $_FILES that are submitted. But it still didn't work, it almost feels like script is called before files are created.
The actual way I am trying to make it work is:

Not:
Select -> Submit -> Upload -> Resize -> Save

But rather:

Select -> Submit -> Upload -> Save -> Resize -> Overwrite


My code is:
function ImageResize($imgs){
$files = glob('/content/sites/k/c/kcrarea.com/web/components/com_rsform/uploads/*.{jpeg,jpg,gif,png}', GLOB_BRACE);
$ph = $imgs;
print_r($_FILES['form']['name']);
foreach($ph as $p){
	foreach($files as $f){
		if(strpos($f, $p) != false){
			list($width, $height) = getimagesize($f);
				if($width > 650 || $height > 450){
					$ratio = 0;
						if($width > 650){
							$ratio = 650/$width;
							}
						else if($height > 450){
							$ratio = 450/$height;
							}
				}
				$filename_from_url = parse_url(strtolower($f));
				$ext = pathinfo($filename_from_url['path'], PATHINFO_EXTENSION);
			switch($ext){
			case "jpg":
			$tcimg = imagecreatetruecolor($width*$ratio, $height*$ratio);
			$img = imagecreatefromjpeg($f);
			imagecopyresized($tcimg, $img, 0,0,0,0, $width*$ratio, $height*$ratio, $width, $height);
			imagejpeg($tcimg, $f, 80);
			echo("DONE");
			break;
			}
		}
	}
}

And in $thankyou I am trying calling this:
<?php
include 'ImageResize.php';
 
ImageResize('{Image1:path}');
?>
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!