Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Automatically resizing imported images 13 Nov 2012 17:51 #5339

How can i automatically resize the images being uploaded to my component? Tried simply replacing 'auto' with '450' in mycomponent_fly.php file. Returns "Not supported" on website. I have 2 images being imported and I need to set 2 different widths.

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

Re: Automatically resizing imported images 15 Nov 2012 10:41 #5373

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
This is because you must define new sizes in the classes/images.php at the top of the file.
It is a security.
Coding is now a piece of cake

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

Re: Automatically resizing imported images 15 Nov 2012 13:51 #5381

OK I found the file but, i'm not sure which setting to change. The top "define" section or "protected" section? I tried changing this line "SHRENTALS_IMAGES_MAX_WIDTH", 500);

My image was still full size.


@define("SHRENTALS_IMAGES_MAX_WIDTH", 1000);
@define("SHRENTALS_IMAGES_MAX_HEIGHT", 1000);
@define("SHRENTALS_IMAGES_ALOWED_SIZES", '');
@define("SHRENTALS_IMAGES_PHYSICAL_THUMB", true); //Create an hidden thumb file with parameters
@define("SHRENTALS_IMAGES_FALLBACK_NAME", ".notfound.png");
@define("SHRENTALS_IMAGES_FALLBACK_ROOT", JPATH_ADMIN_SHRENTALS .DS. "images");

require_once(JPATH_ADMIN_SHRENTALS .DS. "classes" .DS. "file.php");


class ShrentalsImages extends ShrentalsFile
{


protected $file;
protected $dir;
protected $mime;
protected $image_width;
protected $image_height;
protected $width;
protected $height;
protected $ext;
protected $types = array('', 'gif', 'jpeg', 'png', 'bmp');
protected $top = 0;
protected $left = 0;
protected $type;
protected $name;
protected $info;

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

Re: Automatically resizing imported images 21 Nov 2012 10:28 #5553

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
@define("SHRENTALS_IMAGES_MAX_WIDTH", 1000);
@define("SHRENTALS_IMAGES_MAX_HEIGHT", 1000);
@define("SHRENTALS_IMAGES_ALOWED_SIZES", '200x200'); //HERE
Coding is now a piece of cake

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

Last edit: by admin.

Re: Automatically resizing imported images 27 Nov 2012 14:23 #5659

Ok i edited the line to read..

@define("SHRENTALS_IMAGES_ALOWED_SIZES", '400x400');

but my images are still importing at the original size. Did I miss something?

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

Re: Automatically resizing imported images 02 Dec 2012 10:38 #5711

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Yes, of course, your images are uploaded in original sizes.

Cook create thumbs (copies) and put them in same folder with a '.' before (hidden file on UNIX)
You can decide to allow or not the physical thumb file creation.

If not, the image is outputed resized to optimize the file transfert. But using this functionality (not physical), you will use more CPU to generate.

For security, in both cases, you restrict the possible sizes, in order to :
- Do not allow attacks, creating too much thumbs
- Do not allow resizing incredible huge sizes and consuming CPU (DDOS)


Now, in your case, if you do not want to keep the original file :
- Delete it
- Replace the file by its generated thumb

(For this, my advice is to add a parameter, so you will be able to use it natively, or replacing file from anywhere in your component)

Hope it helps.
Coding is now a piece of cake

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

  • Page:
  • 1
Time to create page: 0.063 seconds
Je suis vraiment impressionné par la puissance de COOK et encore plus admiratif de ton travail. A ce jour je crois que c'est ce que j'ai vu de plus abouti dans le domaine de la conception d'extension pour Joomla!
felichon (Forum)  

Get Started