Specifying An Image Directory

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
gmusgrave
Posts: 25
Joined: 2013-08-15 17:27
Location: Mexico

Specifying An Image Directory

Post by gmusgrave » 2015-07-01 21:02

I have a database of Children's Art with three tables. Each row in each of these tables contains an image plus data associated with the image (Artist, Age, Date, etc.).

Each of the three tables contains a few hundred images, and growing.

Because each table is a separate collection, I'd really like the images associated with each table to be stored in a separate directory.

Right now, all images from all tables are stored in a single directory called "images".

Is there a way to specify a different directory for each table? Where in the code is the directory determined?

Thanks for any help,
Garry Musgrave

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Specifying An Image Directory

Post by peebee » 2015-07-01 22:31

You can change the upload directory easily in defaultLang.php

Edit this line (around 14) : $Translation['ImageFolder'] = './images/';

Individual folders for individual tables might involve a bit more work to achieve but it looks possible.

I haven't tried it but I see Uploads are controlled in lib.php by this function (somewhere around line 144):

Code: Select all

function getUploadDir($dir){
There's an array in link.php

Code: Select all

$p=array(   
		'tablename' => array(
			'fieldname' => $Translation['ImageFolder'],
			'fieldname2' => $Translation['ImageFolder'],
and the getUploadDir function in each tables" tablename_dml.php

I would imagine you could create a new "function getUploadDir", "function getUploadDir1", "function getUploadDir2", etc for each table and then add new $Translation['ImageFolder'] = './images1/'; etc in defaultLang.php, change the array in link.php and edit tablename_dml.php?

I can't think of a simpler way to do it but would welcome any other suggestions myself. I now have image folders on some old Appgini projects that have hit 2gb. Perhaps a future upgrade suggestion for Appgini would be the ability to specify an upload folder? Even better to separate image uploads from document uploads or even on per basis rather than per table?

gmusgrave
Posts: 25
Joined: 2013-08-15 17:27
Location: Mexico

Re: Specifying An Image Directory

Post by gmusgrave » 2015-07-02 12:32

Thanks peebee. That's a big help, and should point me in the right direction.

It looks like some custom coding will do what I want, but the disadvantage, as always, is that updates to AppGini clobber the custom code, and it needs to be reinstated in the new version.

Personally, I'd like to see the upload directory as an option in AppGini on the "Media" tab where you set the field to be an "Image." The "Configure..." button brings up a number of options for this field, and this is where I think it should be able to be specified.

Maybe this will be included in a future update. I've reiterated this as a request in "Feature Suggestions."

Post Reply