#1
Hi all,
In the TG single file uploader we get a directory for the Thumbnail. I would like to have an additional directory for an additional size. So for example, I would eventually have Desktop, Tablet and Mobile versions of the image, I can then use srcset or inline media queries in my code to select the right size image for the device size. This approach would speed up page loads.

I could write my own code to do all of this, but it seems a shame to not make use of the Trongate picture settings.
I have so far taken the following approach, and have succeeded in a new Tablet directory been created. but no image gets loaded to the new directory and the Thumbnail image appears incorrect now as the image is taking on the wrong size and is blurry.

Here are the changes I made.

In Trongate.php
public function upload_picture($data) {}
I added


and then in my Controller file looks like this from function _init_picture_settings() {}

#2
Hello John,
Just taking a guess. Check what $thumbnail_dir. is showing.
Also check what $tablet_dir is showing.
Che the code below to the points to troubleshoot.



Hope this helps,
Dan
#3
Hi Dan, thanks for the pointers.

The JSON checks seems to suggest that the right data is being produced. In fact within submit_upload_picture($update_id){}

if I add a further json check

I get the following response. (deprecation warnings aside in Image.php)

which suggest that the right information is being sent via $this->upload_picture($config);

Now moving to Trongate.php where we find the upload_picture function, that passes its data to save_that_pic and a json statement here at line 225



returns

So, it would seem from all of this, that something is going wrong after this point. I will keep digging further. But any insights gratefully recieved.

Thanks
#4
Hello John,
The only other thing I can think of is to try to save the image one at a time.
Upload and save the Thumbnail first and the Upload and save the Tablet next.

By doing it this way it would separate the two tasks you are trying to accomplish,
and maybe help sort it out.

Dan
#5
Hi Dan, thanks for the suggestion.

I think the solution I am going to go for is similar.

I am going to write a function that runs after the completion of the single image uploader. The function would just create another directory and then copy and resize the image from the original folder.

I will let you know how I get on.
#6
So, I have solved the first part of this now, which is to have a new directory added with a new resized images for tablet devices.

1) In the Controller file in function submit_upload_picture($update_id) {}
I added some code to create a new directory.
2) I created a new function tablet_image($source, $destination, $size, $quality=null) {}
This gets called towards the end of function submit_upload_picture($update_id) {}
You can add an integer in $size like 50 , and this will reduce the image size by 50%

I now need to work on the delete part, but feeling good.
#7
Nice Glad you are making progress