DMXzone Image Processor Support Product Page

Answered

Sequence of Events - Image uploads, resize, create thumbnail, save to database

Asked 03 Jun 2016 22:59:37
1
has this question
03 Jun 2016 22:59:37 Steve Skinner posted:
You have great video tutorials for each of these things separately, but I'm a little mystified when it comes to putting all of these things together (upload, resize, thumbnail, save to database).

Take for example, a car database, where you'd have some text fields, and images for full size and thumbnail. In building the admin tool for inserting records, what is the proper sequence of events as it's being set up in server connect? Any tips on chaining this common string of events together with your new extensions?

Replies

Replied 06 Jun 2016 07:45:38
06 Jun 2016 07:45:38 Teodor Kuduschiev replied:
Hello Steve,
The sequence of events, just follows the logic of what you need to achieve. Server Connect's idea is to allow you to just add the steps you need, between the rest of the steps, which you already have.
So for example if you already have an upload and insert, then you could just add the resize steps before the insert.
In the example you provided you just need to have the following steps:
1. Db Connection
2. FIle Upload
3. Image Load step (for big image) (use file upload as a source)
- resize image
- save image + overwrite to overwrite the original file
4. Image Load step (for thumbnail image) (use file upload as a source)
- resize image
- save image / do not overwrite, but create a second file, for example "thumb_{{name}}{{ext}}"
5. Database Insert
- insert form fields
- insert filename (use file upload as a file name source)

That is all.
Then, if you are uploading an image named: "jaguar.jpg" you will have it resized, saved and then a thumbnail will be created. So you will have "jaguar.jpg" and "thumb_jaguar.jpg" and then "jaguar.jpg" will be stored in the db.
Replied 06 Jun 2016 18:08:58
06 Jun 2016 18:08:58 Steve Skinner replied:
Thank you Teodor. That's a big help!
Replied 16 Aug 2016 02:55:21
16 Aug 2016 02:55:21 Charles Knight replied:
I'm having the same issue putting all the steps together, how do you add the extra step of multiple uploads being added, resized and save to an alternative database?
Replied 14 Sep 2016 12:25:39
14 Sep 2016 12:25:39 David Woolley replied:
This works fine for me except when I need to update a text field without changing the image.
The Update Record action step at the end is configured like so:

Column: imagetext
Value: {{$_POST.imagetext}}

Column: imagename
Value: {{origImageUpload.name}}
Condition: {{origImageUpload.name}}

This works when following your latest video:
"Use HTML5 File Upload with Update Record Server Action"
Connection
File Upload
Database Update

Add an image to upload and update text - no problem
Update text field only - imagename is retained & text updated.

But when I add the 6 Image Processor steps like in your email above, it works fine when another image is uploaded and text field changed, but not if text field only is updated.
I tried to find the problem in Chrome with the Developer Tools.
It's complaining about not being able to destroy the image >>

Quote500 internal server error:
.. first section deleted ..
Stack trace:
#0 [internal function]: exception_error_handler(2, 'imagedestroy() ...', 'D:\Documents\Si...', 26, Array)
#1 D:\Documents\Sites XAMPP\digipath2015\dmxConnectLib\lib\image\Processor.php(26): imagedestroy(NULL)
#2 [internal function]: lib\image\Processor->__destruct()
#3 {main}
thrown in <b>D:\Documents\Sites XAMPP\digipath2015\dmxConnectLib\lib\image\Processor.php</b> on line <b>26</b><br />



Replied 14 Sep 2016 13:02:51
14 Sep 2016 13:02:51 Teodor Kuduschiev replied:
Hello,
If you just placed the image processing steps (load image, resize etc.) just after the upload step, they run always - and it is how it is supposed to be, following the steps tree. But when there is no a file uploaded, this error appears - as there is no image to be loaded actually.
You need to put the image process steps in a condition, which checks if there is an actual upload
So the condition must have a value of {{uploadStepName}}
Example:
....
Upload
Condition {{uploadStepName}}
then -> load image, process, save
else -> [empty]
Update
....
Replied 14 Sep 2016 13:17:38
14 Sep 2016 13:17:38 David Woolley replied:
Thanks a lot Teodor! All working now.
Dave
Replied 21 Sep 2016 08:54:33
21 Sep 2016 08:54:33 David Woolley replied:
Since the latest updates a few days ago to the database extensions including Server Connect, the condition statement above has reversed like so:

Upload
Condition
Else
Then
Update

Action executor still works though!

I've just setup a new action with a condition statement, and same thing:
The Else statement shows before Then statement.

Dave
Replied 21 Sep 2016 09:10:55
21 Sep 2016 09:10:55 Teodor Kuduschiev replied:
Hi David,
This is not a problem and not something new. This is how the steps are being read by DW ... it doesn;t matter if else is first or then is first.
Replied 21 Sep 2016 09:18:26
21 Sep 2016 09:18:26 David Woolley replied:
Thanks Teodor - just seemed a bit odd
Dave

Reply to this topic