You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your fantastic plugin. I'm so glad it's out here, because it works great.
In my project I have a standard form in which people can upload 5 images. These images are stored as file attachment in System\Models\File. Right now I'm uploading the images in their original uncompressed form and resize them when they appear on the frontend, using the twig filter {{ '/path/to/image.jpg' | resize(250, 100) }}. This works great, but I'd like to compress the original images as well.
A nice rule I'm having in my head is forcing images not to exceed 1000 by 1000 pixels, and also running them by TinyPNG. This way, I'd save a lot of disk space, because I'm seeing images of 10MB+ in this project.
I've noticed we can use your plugin in PHP too. Is it possible to save the compressed image and to replace the original? Something like:
use ToughDeveloper\ImageResizer\Classes\Image;
use ThirdPartyDeveloper\CarManager\Models\Car;
// Create a new instance of car based on user input
$car= new Car();
$car->name = Input::get('car_name');
$car->save();
// Compress image
$image = new Image(Input::file('car_image'));
$image->resize(1000, 1000);
// Attach compressed image
$car->images()->create(['data' =>$image]);
Would something like this be possible? I was experimenting with another plugin, but kept running into problems.
A second part of the question is: would we be able to do something like the linked plugin, where we compress images as soon as they appear in the media library?
What are your thoughts?
Thanks in advance.
The text was updated successfully, but these errors were encountered:
chocolata
changed the title
Resizing on upload
Resizing original image on upload
Mar 16, 2018
Hi,
Thanks for your fantastic plugin. I'm so glad it's out here, because it works great.
In my project I have a standard form in which people can upload 5 images. These images are stored as file attachment in
System\Models\File
. Right now I'm uploading the images in their original uncompressed form and resize them when they appear on the frontend, using the twig filter{{ '/path/to/image.jpg' | resize(250, 100) }}
. This works great, but I'd like to compress the original images as well.A nice rule I'm having in my head is forcing images not to exceed 1000 by 1000 pixels, and also running them by TinyPNG. This way, I'd save a lot of disk space, because I'm seeing images of 10MB+ in this project.
I've noticed we can use your plugin in PHP too. Is it possible to save the compressed image and to replace the original? Something like:
Would something like this be possible? I was experimenting with another plugin, but kept running into problems.
A second part of the question is: would we be able to do something like the linked plugin, where we compress images as soon as they appear in the media library?
What are your thoughts?
Thanks in advance.
The text was updated successfully, but these errors were encountered: