Page 1 of 1

dropdown list for image download

Posted: 11 Aug 2010, 05:09
by siasan
I'm building a site for downloading desktop backgrounds and I'd like to have several sizes/aspect rations available for each image. I thought of putting each set of images in a sub-category so users can choose the appropriate size, but this is a very clumsy solution. What I'd really like is to replace the 'download' button with a dropdown list that shows the available resolutions.

So, my question...

1. Is this possible?
2. if so, can somebody please point me in the direction of the appropriate resources to implement it?

Thanks in advance for any help.

Re: dropdown list for image download

Posted: 12 Aug 2010, 02:39
by siasan
What, no replies? Here's what might be a better explanation:

There are 2 images that are identical except that one is 4:3 resolution and the other is 16:10. I could put these in the gallery as two separate images, but it would be better to have a single thumbnail that provides links to download both sizes of the large image.

Basically, two (or more) images forming a 'family' that is represented by a single thumbnail.

Re: dropdown list for image download

Posted: 12 Aug 2010, 03:58
by siasan
Okay, I'm now trying to find my way towards a solution...

I could hack the 'insert image' section of Phoca to add an extra database query that inserts name, file path (same as base file path but with resolution appended) and resolution into an additional table. Then a custom download dropbox would be populated with the available resolutions. A user would select a resolution, which would open in the modal box and allow download.

My second alternative is to develop an entirely separate custom module that inserts new rows into my table. I'd prefer the automated version, but this one is likely to be a more flexible tool. Having looked through the Phoca code, this looks like an easier solution. However, I would still need to create my own download button and I haven't yet located the part of the code I need to modify.

Does anyone have any suggestions, alternatives or advice?

Re: dropdown list for image download

Posted: 13 Aug 2010, 02:06
by siasan
36 views and nobody has any suggestions...

Re: dropdown list for image download

Posted: 13 Aug 2010, 03:03
by imperialWicket
One solution might be to edit the view that you are using such that you remove the current download icon, and replace it with a few custom icons. Then manually generate the appropriate links to the various sizes (either with database calls, parsing, or hard-coding... depends a little bit on your config).

Re: dropdown list for image download

Posted: 16 Aug 2010, 02:06
by siasan
Yes, that's exactly what I want to do. I'm not too worried about doing a bit of programming/data entry, but so far I haven't been able to find the right place in the code to add in the extra functions I want.

Ideally it will replace the download button below the thumbnail either with a couple of icons to different image sizes or else a dropdown menu of available sizes. Either way, I really need to find the right place in the Phoca code...

First question: what file draws the part of the page with the existing download button in it?

Second/third question: how does Phoca communicate with the database? Is there an existing 'database connect' class that I can use?

Re: dropdown list for image download

Posted: 16 Aug 2010, 04:33
by imperialWicket
If you are displaying "Category Layout" with a number of thumbnail boxes on it, then the download icon is added at line 344 of the components/com_phocagallery/views/category/tmpl/default.php file (line number is from the 2.7.4 release). The actual download icon is added at 362. I'm thinking it would be easiest to add two or three distinct download icons, each representing a resolution, and manually build the download URLs for the additional resolutions.

Phoca adheres to the Joomla recommended MVC framework pretty well. The database connectivity occurs in the model files, and all of the display occurs in the views. There is some overflow, because the models occasionally send data to the views that includes html markup, but this is easily modified either on the model side or the view side. Joomla has database connection utilities, there are a lot of examples in the Phoca Gallery models (I imagine component/com_phocagallery/models/detail.php will be of most interest for your present pursuit).

I have not made any changes to the download behavior, but I imagine you will have to pass an additional or alternative parameter to the download request, and then handle that parameter in order to download the alternate resolution images. Someone can correct me here if I am wrong, but I do not think that there is currently a feature that allows downloading the various sizes - it always downloads the original. Like I said - have not had the need to customize this code, apologies if I am giving you any inaccurate info.

Re: dropdown list for image download

Posted: 02 Feb 2011, 02:19
by Demonike
I guess it would make sense to build this into the component in a future release. I am in need of the same thing, for a Desktop images section in a portal, but I am in no position to hack the code at such an advanced level.

Logically, the option could be in image detail view in the backend, radio button to select "Multiple resolutions" and then, say five sets of fields (widths and heights for automatic "thumbnail" generation and one field for each size which enables to override the "downsampling" and choose the alternative ready-made image from a folder). Ready-made files would be necessary in cases where 16:10 and 4:3 are custom designed and cannot tolerate cropping.

OR, not to limit the number of different resolutions, there is a possibility to designate a specific folder, with all of the image variations in it, Phoca would read all the images and construct the drop-down from their sizes automatically. This could be done in the categories part perhaps...

Looking forward to it. The software is excellent so far, considering it is totally free. Seems like a full-time job to me for the author :o :twisted: