Forums

Resize suffix problem

Riceman 30 Jun, 2012
I have a number of images being uploaded and Resized and recorded in a DB, in CFv4.

All systems are go except for one problem. The name that is saved in the DB does NOT include the suffix that is added in the Resize config.

AS a workaround I tried not having any suffix...but "_big" was automatically added, even though in the "Actions" Config that field is blank.

How can I get the suffix added to the name that is inserted in the DB?

My Actions workflow is:

On Submit:
Upload Files
Image Resize (one instance for each image- a total of 11)
DB Save
Email
GreyHead 30 Jun, 2012
Hi Riceman,

It looks as though the Image Resize action doesn't save any data to the $form->data array (it probably should). The only way would be to use a Custom Code action to re-create the new image file name before saving to the database.

Bob
Riceman 30 Jun, 2012
I am familiar with the Custom Code Action, but have no idea on how to accomplish the task. In reality, i don't even need the suffix...is there a way to not have the "_big" added, or are we again looking at a Custom Code Action.

Either way, I would appreciate some help on what that code would be, and would of course be happy to contribute to the beer supply in return.
Riceman 04 Jul, 2012
Aloha GreyHead,

I would love to get some help here and am happy to either pay for beer via your signature or maybe hire you to do the work. This is the last big hurdle for our all important form.

Looking forward to your reply.
Riceman 06 Jul, 2012
I hate to be a pest, ...but (the infamous "but"). I really need to find a way to either:
[list]• Get rid of the suffix altogether
• Have it added to the DB field
• Find a workaround[/list]

The problem for me is we are calling with php the field data into a page like so
<img src="../../upload/resize/<?php echo $slide_1; ?>"
so the php pulls the DB field, and there is no way to work with the suffix, if it were a prefix we could do something like this
<img src="../../upload/resize/prefix_<?php echo $slide_1; ?>"
But, that's obviously not the case.

This is our last necessary step before going live, that's why I'm pestering. And of course willing to buy beer for the help.
GreyHead 09 Jul, 2012
Hi Riceman,

I think that the quickest fix is to edit the administrator/components/com_chronoforms/form_actions/image_resize/image_resize.php file. Look for this code near the end and replace '_big' with ''
				'big_image_prefix' => '',
				'big_image_suffix' => '_big',
				'big_image_height' => '300',
				'big_image_width' => '400',


If you post a debug listing here so that I can see the names and values I'll try to write some code to remove the suffix for you as a better solution.

Bob
Riceman 10 Jul, 2012
Thanks for the help, the quick fix can certainly work for now, but the proper code would be ideal for any updating of the component. Here is the debug data:

Array
(
    [chronoform] => PropertySubmissionMobile-Img
    [event] => submit
    [Itemid] => 11
    [option] => com_content
    [view] => article
    [id] => 1
    [full_name] => TEST
    [company] => TEST
    [company_logo] => 
    [phone] => TEST
    [email] => 
 test@test.com
    [mls] => 123456
    [county] => TEST
    [property_name] => TEST
    [price] => TEST
    [prop_location] => TEST
    [prop_description] => TEST
    [num_beds] => 1
    [num_bath] => 1
    [living_area] => TEST
    [land_area] => TEST
    [neighborhood] => TEST
    [youtube_url] => 
    [slide_1] => 20120709190816_image01.jpg
    [slide_2] => 20120709190816_image02.jpg
    [slide_3] => 20120709190816_image03.jpg
    [slide_4] => 
    [slide_5] => 
    [slide_6] => 
    [slide_7] => 
    [slide_8] => 
    [slide_9] => 
    [slide_10] => 
    [chrono_verification] => hGKpw
    [input_submit_8] => Submit
    [08b3db974a541be028d6ef31d0f12b92] => 1
    [_PLUGINS_] => Array
        (
            [upload_files] => Array
                (
                    [slide_1] => Array
                        (
                            [name] => 20120709190816_image01.jpg
                            [path] => listings/upload/20120709190816_image01.jpg
                            [size] => 91532
                            [link] => listings/upload/20120709190816_image01.jpg
                        )

                    [slide_2] => Array
                        (
                            [name] => 20120709190816_image02.jpg
                            [path] => listings/upload/20120709190816_image02.jpg
                            [size] => 132314
                            [link] => listings/upload/20120709190816_image02.jpg
                        )

                    [slide_3] => Array
                        (
                            [name] => 20120709190816_image03.jpg
                            [path] => listings/upload/20120709190816_image03.jpg
                            [size] => 113583
                            [link] => listings/upload/20120709190816_image03.jpg
                        )

                )

        )

    [chronoform_data] => Array
        (
            [cf_uid] => c0dcca8db3e7f0eba6984718cd1fde51
            [cf_created] => 2012-07-09 19:08:18
            [cf_ipaddress] => 70.95.105.226
            [cf_user_id] => 62
            [chronoform] => PropertySubmissionMobile-Img
            [event] => submit
            [Itemid] => 11
            [option] => com_content
            [view] => article
            [id] => 1
            [full_name] => TEST
            [company] => TEST
            [company_logo] => 
            [phone] => TEST
            [email] => 
 test@test.com
            [mls] => 123456
            [county] => TEST
            [property_name] => TEST
            [price] => TEST
            [prop_location] => TEST
            [prop_description] => TEST
            [num_beds] => 1
            [num_bath] => 1
            [living_area] => TEST
            [land_area] => TEST
            [neighborhood] => TEST
            [youtube_url] => 
            [slide_1] => 20120709190816_image01.jpg
            [slide_2] => 20120709190816_image02.jpg
            [slide_3] => 20120709190816_image03.jpg
            [slide_4] => 
            [slide_5] => 
            [slide_6] => 
            [slide_7] => 
            [slide_8] => 
            [slide_9] => 
            [slide_10] => 
            [chrono_verification] => hGKpw
            [input_submit_8] => Submit
            [08b3db974a541be028d6ef31d0f12b92] => 1
            [_PLUGINS_] => Array
                (
                    [upload_files] => Array
                        (
                            [slide_1] => Array
                                (
                                    [name] => 20120709190816_image01.jpg
                                    [path] => listings/upload/20120709190816_image01.jpg
                                    [size] => 91532
                                    [link] => listings/upload/20120709190816_image01.jpg
                                )

                            [slide_2] => Array
                                (
                                    [name] => 20120709190816_image02.jpg
                                    [path] => listings/upload/20120709190816_image02.jpg
                                    [size] => 132314
                                    [link] => listings/upload/20120709190816_image02.jpg
                                )

                            [slide_3] => Array
                                (
                                    [name] => 20120709190816_image03.jpg
                                    [path] => listings/upload/20120709190816_image03.jpg
                                    [size] => 113583
                                    [link] => listings/upload/20120709190816_image03.jpg
                                )

                        )

                )

            [cf_id] => 19
        )

    [chronoform_data_cf_id] => 19
)


and attached is a screen capture image of what is put in the directory, note the suffix:
[attachment=0]Screen Shot 2012-07-09 at 2.21.44 PM.png[/attachment]
GreyHead 10 Jul, 2012
Hi Riceman,

I moved your last post into this thread - it seemed to have strayed.

Here's a first attempt at doing this. This code should got into a Custom Code action after the Upload Files action.
<?php
jimport('joomla.filesystem.folder');
$path = JPATH_SITE.DS.'listings'.DS.'upload'.DS;
$files = JFolder::files($path, '_big');
foreach ( $files as $f ) {
  $f_new = str_replace('_big', '', $f);
  JFolder::move($path.$f, $path.$f_new);
}
?>

Bob
Riceman 10 Jul, 2012
Not yet...

here is what I've done, I also tried this after the Resize Actions with same results:
[attachment=2]action.png[/attachment]
[attachment=1]action_settings.png[/attachment]

Results in DB:
[attachment=0]db_names.png[/attachment]
Results in Directory:
20120710154554_image01_bigtest.jpg
20120710154554_image02_big.jpg
20120710154554_image03_big.jpg
20120710154554_image04_big.jpg

Thanks for the help!!
GreyHead 10 Jul, 2012
Hi Riceman,

It should be after the Upload Files and Resize actions. Please try this version with some added debug code to see if was can work out what is happening.
<?php
$mainframe =& JFactory::getApplication();
jimport('joomla.filesystem.folder');
$path = JPATH_SITE.DS.'listings'.DS.'upload'.DS;
$mainframe->enqueuemessage('$path: '.print_r($path, true).'<hr />');
$files = JFolder::files($path, '_big');
$mainframe->enqueuemessage('$files: '.print_r($files, true).'<hr />');
foreach ( $files as $f ) {
  $f_new = str_replace('_big', '', $f);
  $mainframe->enqueuemessage('$f: '.print_r($f, true).'<hr />');
  $mainframe->enqueuemessage('$f_new: '.print_r($f_new, true).'<hr />');
  JFolder::move($path.$f, $path.$f_new);
}
?>
This should output a string of system messages at the top of the page.

Bob
Riceman 11 Jul, 2012
Here are the results:

Array
(
    [chronoform] => PropertySubmissionMobile-Img
    [event] => submit
    [Itemid] => 11
    [option] => com_chronoforms
    [view] => form
    [full_name] => TEST
    [company] => TEST
    [company_logo] => 
    [phone] => TEST
    [email] => test@test.com
    [mls] => 123456
    [county] => TEST
    [property_name] => TEST
    [price] => TEST
    [prop_location] => TEST
    [prop_description] => TEST
    [num_beds] => 1
    [num_bath] => 1
    [living_area] => TEST
    [land_area] => TEST
    [neighborhood] => TEST
    [youtube_url] => 
    [slide_1] => 20120710210559_image01.jpg
    [slide_2] => 20120710210559_image02.jpg
    [slide_3] => 20120710210559_image03.jpg
    [slide_4] => 20120710210559_image04.jpg
    [slide_5] => 
    [slide_6] => 
    [slide_7] => 
    [slide_8] => 
    [slide_9] => 
    [slide_10] => 
    [chrono_verification] => BdpYG
    [input_submit_8] => Submit
    [3c97e5cc6e7a6274835c2450598123ba] => 1
    [_PLUGINS_] => Array
        (
            [upload_files] => Array
                (
                    [slide_1] => Array
                        (
                            [name] => 20120710210559_image01.jpg
                            [path] => listings/upload/20120710210559_image01.jpg
                            [size] => 91532
                            [link] => listings/upload/20120710210559_image01.jpg
                        )

                    [slide_2] => Array
                        (
                            [name] => 20120710210559_image02.jpg
                            [path] => listings/upload/20120710210559_image02.jpg
                            [size] => 132314
                            [link] => listings/upload/20120710210559_image02.jpg
                        )

                    [slide_3] => Array
                        (
                            [name] => 20120710210559_image03.jpg
                            [path] => listings/upload/20120710210559_image03.jpg
                            [size] => 113583
                            [link] => listings/upload/20120710210559_image03.jpg
                        )

                    [slide_4] => Array
                        (
                            [name] => 20120710210559_image04.jpg
                            [path] => listings/upload/20120710210559_image04.jpg
                            [size] => 110206
                            [link] => listings/upload/20120710210559_image04.jpg
                        )

                )

        )

    [chronoform_data] => Array
        (
            [cf_uid] => 10a547f729e75afb1c25a7f5036af345
            [cf_created] => 2012-07-10 21:05:59
            [cf_ipaddress] => 70.95.105.226
            [cf_user_id] => 62
            [chronoform] => PropertySubmissionMobile-Img
            [event] => submit
            [Itemid] => 11
            [option] => com_chronoforms
            [view] => form
            [full_name] => TEST
            [company] => TEST
            [company_logo] => 
            [phone] => TEST
            [email] => test@test.com
            [mls] => 123456
            [county] => TEST
            [property_name] => TEST
            [price] => TEST
            [prop_location] => TEST
            [prop_description] => TEST
            [num_beds] => 1
            [num_bath] => 1
            [living_area] => TEST
            [land_area] => TEST
            [neighborhood] => TEST
            [youtube_url] => 
            [slide_1] => 20120710210559_image01.jpg
            [slide_2] => 20120710210559_image02.jpg
            [slide_3] => 20120710210559_image03.jpg
            [slide_4] => 20120710210559_image04.jpg
            [slide_5] => 
            [slide_6] => 
            [slide_7] => 
            [slide_8] => 
            [slide_9] => 
            [slide_10] => 
            [chrono_verification] => BdpYG
            [input_submit_8] => Submit
            [3c97e5cc6e7a6274835c2450598123ba] => 1
            [_PLUGINS_] => Array
                (
                    [upload_files] => Array
                        (
                            [slide_1] => Array
                                (
                                    [name] => 20120710210559_image01.jpg
                                    [path] => listings/upload/20120710210559_image01.jpg
                                    [size] => 91532
                                    [link] => listings/upload/20120710210559_image01.jpg
                                )

                            [slide_2] => Array
                                (
                                    [name] => 20120710210559_image02.jpg
                                    [path] => listings/upload/20120710210559_image02.jpg
                                    [size] => 132314
                                    [link] => listings/upload/20120710210559_image02.jpg
                                )

                            [slide_3] => Array
                                (
                                    [name] => 20120710210559_image03.jpg
                                    [path] => listings/upload/20120710210559_image03.jpg
                                    [size] => 113583
                                    [link] => listings/upload/20120710210559_image03.jpg
                                )

                            [slide_4] => Array
                                (
                                    [name] => 20120710210559_image04.jpg
                                    [path] => listings/upload/20120710210559_image04.jpg
                                    [size] => 110206
                                    [link] => listings/upload/20120710210559_image04.jpg
                                )

                        )

                )

            [cf_id] => 25
        )

    [chronoform_data_cf_id] => 25
)
GreyHead 11 Jul, 2012
Hi Riceman,

Hmmm . . . I don't see the output there. Maybe your template doesn't support System messages. I'll try to build a local test when I have a moment.

Bob
Riceman 11 Jul, 2012
There was this in the System Message, sorry I didn't think it was relevant(thought you wanted the "Data Array":

Message

$path: /home/adms808/public_html/listings/upload/
$files: Array ( ) 


and then this below the Debugger Code:
Debug Data

    Core Captcha
        Passed the core captcha check!
    Upload routine started for file upload by : slide_1
    listings/upload/20120711110854_image01.jpg has been uploaded OK.
    Upload routine started for file upload by : slide_2
    listings/upload/20120711110854_image02.jpg has been uploaded OK.
    Upload routine started for file upload by : slide_3
    listings/upload/20120711110854_image03.jpg has been uploaded OK.
    Upload routine started for file upload by : slide_4
    listings/upload/20120711110854_image04.jpg has been uploaded OK.
    email
        0
            Result An email has been SENT successfully from (Admin)XXXXXXXXXXXX@realestatemobileservices.com to XXXXXXXXXXXX@realestatemobileservices.com
            Body CF_ID - 26

            USER_ID - 62

            Realtor Info
            Full Name 	TEST
            Company Name 	TEST
            Company Logo 	
            Phone 	TEST
            Email 	test@test.com
              	 
              	 
            Property Info
            MLS# 	123456
            County 	TEST
            Property Name 	TEST
            Property Price 	TEST
            Property Location 	TEST
            Property Description 	TEST
            Number of Bedrooms 	1
            Number of Baths 	1
            Living Area 	TEST
            Land Area 	TEST
            Neighborhood/Condo 	TEST
            YouTube Video Url 	{video}
              	 
              	 
            Slideshow Upload
            Slide 1 	20120711110854_image01.jpg
            Slide 2 	20120711110854_image02.jpg
            Slide 3 	20120711110854_image03.jpg
            Slide 4 	20120711110854_image04.jpg
            Slide 5 	
            Slide 6 	
            Slide 7 	
            Slide 8 	
            Slide 9 	
            Slide 10 	
              	 
              	 
              	 
              	 


            Submitted by 70.95.105.226
            Attachments array ( )

GreyHead 11 Jul, 2012
Hi Riceman,

The good news is that was the output I wanted, the bad news is that it isn’t finding any files with _big in the name :-(

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
GreyHead 20 Jul, 2012
Hi Riceman,

Sorry for the long delay. This is working now. There were two small changes needed, the path in the code wasn't the one where the images were saved (that explains the empty list) and it needed to be JFile::move instead of JFolder::move (which moves whole folders). Here's the updated code:
<?php
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$path = JPATH_SITE.DS.'listings'.DS.'upload'.DS.'resize'.DS;
$files = JFolder::files($path, '_big');
foreach ( $files as $f ) {
  $f_new = str_replace('_big', '', $f);
  JFile::move($path.$f, $path.$f_new);
}
?>

Bob

PS I installed the free exTplorer extension to see the file folders from the Admin. Please keep it or delete it as you like.
Riceman 20 Jul, 2012
Big Mahalo!!! I'm gotta but you a beer for that. One last questions, what is the likelihood of images being duplicated in the upload folder with the naming convention CF uses?
GreyHead 21 Jul, 2012
Hi Riceman,

The chances of duplication are vanishingly small. The number string is a date and time so it would require two upload with the same file name in the same second.

Bob
Riceman 21 Jul, 2012
Got it, Thanks again!
esl 15 Nov, 2012
I am also having problems with the resize function i tried adding the code in your post to a custom code in after upload, and resize and I got this error

"JFolder::files: Path is not a folder:"
GreyHead 15 Nov, 2012
Hi esl,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.

Note: if you are using the Easy Wizard you can turn on Debug on the Others tab.

Bob
This topic is locked and no more replies can be posted.