[DownloadLink] New Module

alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2008-05-28 11:06

Now in the community repository, see the "add more plugins" page.

Note: this module was called download, but on uploading it to the repository I see that there already exists a download module, that does something similar although without the links and permissions (I don't think it ever got to the stage of being automatically installable) so I've renamed this one downloadlink. Sorry for the inconvenience. If you're using it under its previous name you should probably uninstall that, delete it, and then install this one.

I've updated the download module I created for someone, added permissions and some other misc stuff (downloads are now of the preferred derivative rather than the original). A few people might find it useful.

What it does is add a set of "Download Photo" links under each picture - you can set permissions to show the link for originals, resizes (both on by default) and thumbnails (off by default).

If you installed the previous version please *uninstall* that before copying this over and installing - or else you won't see the new permissions.

If it gets a thumbs up from one or two people I'll put it in the repository.

 
tccarpenter

Joined: 2007-03-13
Posts: 13
Posted: Thu, 2008-05-29 02:14

I've updated my download module with the new files. Thank you for the added permissions, just what I needed! The only change I would suggest is not having the permissions for downloads on by default. Allowing downloads would be exceptions rather than the rule at least in my case.

Thanks for your work on this!

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-05-29 07:15
Quote:
I would suggest is not having the permissions for downloads on by default.

But you won't have to answer the flood of "I've installed this module and I can't see any download links! Why doesn't it work?" questions from people who are too lazy or ignorant to read the module description and read that there are permissions to be set.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2008-05-30 04:29

I have created a codex page:
http://codex.gallery2.org/Gallery2:Modules:downloadlink
please feel free to flesh out.
Developers don't like to do documentation, so if you like this module please contribute to helping out by making the documentation better for all.

Dave

PS:
alecmyers, thanks for the continued contribution.

dm
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
tberman333
tberman333's picture

Joined: 2007-12-26
Posts: 41
Posted: Fri, 2008-05-30 19:59

Post Removed...

 
kenholmes

Joined: 2007-10-25
Posts: 4
Posted: Tue, 2008-07-15 06:30

This is an excellent plugin, but is there any way to get a download link on the photo page? Looks like it only displays on the thumbnail page, which is less than optimal. I have large images that I need to offer to the press (3000x2000) and they don't always understand the "right click and chose save target as" instructions, and enlarging a photo that size in a browser is a bit much.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-07-15 08:14
kenholmes wrote:
This is an excellent plugin, but is there any way to get a download link on the photo page? Looks like it only displays on the thumbnail page,

The links display alongside all the other ItemActions, in both album and photo pages. The exact location depends on your theme. For the Matrix (default) theme, this is a typical display on a photo page (see attachment.)

 
Oli4

Joined: 2008-07-15
Posts: 18
Posted: Tue, 2008-07-15 18:27

-deleted-

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2008-07-23 13:49

This module isn't compatible with Gallery 2.3. I've an updated version which I'll put into the repository when 2.3 is formally released.

 
drei

Joined: 2008-04-03
Posts: 1
Posted: Mon, 2008-08-18 10:42

I followed the instructions on the codex page for inserting a link to download the original image.
This link though is now shown no matter how the permissions are set.

Is there a possibility to only show the link if the permission to download the original version is given?

- David.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-08-18 12:46
Quote:
Is there a possibility to only show the link if the permission to download the original version is given?

Of course! you can do anything you like in Gallery....

The best way I think would be to add a callback to the module to check the permission, then you can make display of the link conditional on that permission with smarty {if} {/if} tags.

 
swordfish
swordfish's picture

Joined: 2004-10-01
Posts: 388
Posted: Sat, 2008-08-30 07:21

G2 2.3 RC1 is here (using it now) and I'd really like to use this module. Have it installed but I get a G2 permission denied error when clicking the download link; even as admin. So, guess thats what you mean by not yet compatible with 2.3.

Anyways, looking forward to it when the day comes.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2008-08-30 11:25
Quote:
So, guess thats what you mean by not yet compatible with 2.3.

Yes, the module reuses code from the core.DownloadItem view, which was considerably refactored for 2.3 in a way that breaks downloadlink.

 
swordfish
swordfish's picture

Joined: 2004-10-01
Posts: 388
Posted: Sat, 2008-08-30 18:45

Ah, I see. For now I just removed permission checking in your module and the download link works well.

 
dlongnecker

Joined: 2007-03-08
Posts: 21
Posted: Thu, 2008-10-23 18:19
Quote:
This module isn't compatible with Gallery 2.3. I've an updated version which I'll put into the repository when 2.3 is formally released.

Looks like 2.3 is now available. When my users try to download, the get

Security Violation: The action you attempted is not permitted.

Even I get it with every access right possible. I am hoping your updates will fix it!

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2008-10-24 13:30

I've updated this module to a 2.3-compatible version.

 
blade007

Joined: 2006-08-07
Posts: 12
Posted: Mon, 2008-10-27 00:34

Hi there. Awesome. I'm, going to have have a go with this module.

On my Pure Anime Gallery I was using a bit of code to generate a download link below the image, in photo.tpl

In fact I was using:

{* Download link for item in original format *}

<div class="gbBlock">
{$theme.item.title|default:$theme.item.pathComponent|markup:strip}
{g->text text=" : Right click and save link as to "}
<a href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.item.id`"}">
{g->text text="Download this picture in original format" arg1=$theme.sourceImage.itemTypeName.1}
</a>
</div>

which is probably a bit of a frig, but works. Not very elegant because there's nothing to set it on or off individual albums. I'm going to have a go with yours and see if I can get some more control and cooler results.

 
jfgarcia
jfgarcia's picture

Joined: 2007-11-06
Posts: 11
Posted: Tue, 2009-01-13 15:48

Hi,

I've updated the plugins page but downloadlink doesn't show.

is it normal?

I'd like to allow visitors to download pictures but can't do that...

Thanks.

-----------------------------
Live from Brittany, France...

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2009-01-13 18:05

It's in the community repository. Make sure this option is ticked before you update your plugins list.

 
jfgarcia
jfgarcia's picture

Joined: 2007-11-06
Posts: 11
Posted: Wed, 2009-01-14 13:47

I've done that, but downloadlink is not in the list...

-----------------------------
Live from Brittany, France...

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-01-14 13:57

well, there it is... I don't know what else to say except look again.

 
ttkingdom

Joined: 2007-08-25
Posts: 8
Posted: Sun, 2009-04-12 08:22
blade007 wrote:

{* Download link for item in original format *}

<div class="gbBlock">
{$theme.item.title|default:$theme.item.pathComponent|markup:strip}
{g->text text=" : Right click and save link as to "}
<a href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.item.id`"}">
{g->text text="Download this picture in original format" arg1=$theme.sourceImage.itemTypeName.1}
</a>
</div>

Your piece of code works great with Matrix theme.

However in IE I get a HTTP 500 Error, works with Firefox though

 
TSB

Joined: 2009-04-06
Posts: 2
Posted: Wed, 2009-04-29 14:51

Hi There

Would someone be so kind to supply a direct link to download this plugin as my gallery sits behind a corporate proxy server?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-04-29 14:54

You can download tarballs for all the community modules directly from Sourceforge: in the gallery-contrib project, here:
http://gallery-contrib.svn.sourceforge.net/viewvc/gallery-contrib/trunk/gallery2/modules/

Go into which ever one you want and use the download GNU tarball at the the end of the page.

 
TSB

Joined: 2009-04-06
Posts: 2
Posted: Wed, 2009-04-29 14:58

Thanks for your quick reply! Good plugin by the way :-)

 
kdji123

Joined: 2009-05-05
Posts: 24
Posted: Tue, 2009-05-05 23:20

well this module works pretty fine.
however,i want a little customization. this module shows [Download Photo(size)]
which i want to convert to [Download Wallpaper(size)]
how to do this.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-05-06 08:29
Quote:
which i want to convert to [Download Wallpaper(size)]

Edit the file module.inc - look for something like "Download %s".

 
PaulYaro

Joined: 2009-04-04
Posts: 23
Posted: Sat, 2009-12-12 20:44

Hello alecmyers,
I use Gallery for over year - its excellent and I see you give much work to this project.
I have tried your module downloadlink however my version of gallery is 2.2.4 and for some important reasons cannot be updated. So, I see downloadlink module in repository works only with 2.3, will not work with my Gallery.
I have installed download module but I think it is different a little bit. Would you be so kind to give a link to your old version of module for version 2.2.4 ?
Also, one more question: is it possible to limit item action/download only for one album? However, permissions for parent and other albums MUST allow to view all version for everybody? Is it possible?
Hope you understand my question, sorry for my poor english.
PaulYaro

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2009-12-12 21:25

You can check the old files out of the Subversion repository on Sourceforge, here:
http://gallery-contrib.svn.sourceforge.net/viewvc/gallery-contrib/trunk/gallery2/modules/downloadlink/
There are only three files so it shouldn't take long. You want revision 1379 for the version without the G2.3 changes.

I'm afraid I don't have a zipped version of old code.

Quote:
Also, one more question: is it possible to limit item action/download only for one album?

I don't really understand what you want to do - but in general the G2 permissions system is configurable so that each album and item can have different permissions, so - probably.

 
PaulYaro

Joined: 2009-04-04
Posts: 23
Posted: Sat, 2009-12-12 23:04

Hello alecmyers,
thanks for so quick reply - you are always on-line!
What I see in your link is: update for G2.3
so, no old version.
My second question - sorry if not precise, or I am missing something:
if I set permissions for guests ONLY TO SEE ITEMS in album, nothing more, there is always drop-down action list and download possibility. I would like to give this permission only in some subalbums.
I have checked all permission, but this action is always possible, no metter what I set in permission. Is it my mistake somewhere?
Thanks - PaulYaro

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2009-12-13 02:28
Quote:
You want revision 1379

- Put 1379 in the box for revision number.

Quote:
this action is always possible

If the user/guest doesn't have the relevant [downloadlink] permission then the download link doesn't appear in the menu.

 
PaulYaro

Joined: 2009-04-04
Posts: 23
Posted: Sun, 2009-12-13 10:30

Hi,
thank you very much - version that you recommended works excellent. No problem with permission.
For some reasons version of "download" module (not your downloadlink) had no possibility to set permissions - there was no this option on permission list, simply no!
Thanks again, alecmyers!

 
diegosanchez

Joined: 2009-12-07
Posts: 54
Posted: Mon, 2009-12-14 02:41

hey i had to change the Theme customisation link

from

    <a href="{g->url arg1="view=downloadlink.OfferDownload" arg2="itemId=`$theme.item.id`"}">    Download and save full image</a>

to

<a href="{g->url arg1="view=downloadlink.OfferDownload" arg2="itemId=`$child.id`"}"> Download and save full image</a>

therefore i can click link to download original :)

 
kdji123

Joined: 2009-05-05
Posts: 24
Posted: Wed, 2010-03-10 16:47

[img]http://gallery.menalto.com/files/untitled_10.JPG[/img]

As it can be seen in above pic., the links given by download link module is not in ascending or descending order of image size,But is based on the first digit in the size.
I want the help to make it to be organized on the basis of sizes as the case of "block-core-PhotoSizes" module.

regard.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2010-03-09 22:46
Quote:
As it can be seen in above pic., the links given by download link module is not in ascending or descending order of image size,But is based on the first digit in the size.

That's correct. All the itemAction links are listed alphabetically, not alphanumerically, I think. Not sure where you'll change that. It's not in the downloadlink module, you may have to hack around in your templates to re-sort the array of itemAction links. Good luck.

 
kdji123

Joined: 2009-05-05
Posts: 24
Posted: Wed, 2010-03-10 16:54

the sorting is clearly alphanumerically.

and the change that should be made is in the following code in module inc of downloadlink module.

$itemTypeNames = $item->itemTypeName();
foreach ($potentialImages as $potentialImage) {
$links[$masterId][] =
array('text' => $this->translate(array('text' => 'Download photo(%s x %s)','arg1' =>
$potentialImage->getWidth(),'arg2' => $potentialImage->getHeight())),
'params' => array('view' => 'downloadlink.OfferDownload',
'itemId' => $potentialImage->getId()));
}

someone with php skill can help,
ithink uksort function of arrey will help dont how though.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2010-03-10 17:10
Quote:
and the change that should be made is in the following code in module inc of downloadlink module.

I don't think you can set the order the links are displayed in that bit of code.

I think *all* the links under the item are sorted independently, before they are displayed. If you want to test that, try inserting

asort($potentialImages);

before the 'foreach' loop. If that makes a difference to the order the links are displayed then you can fix the order they're displayed in there. (Post back, and I'll see if I can work out how, for you). If it doesn't make a difference, then I think you'll have to modify code elsewhere.

Quote:
the sorting is clearly alphanumerically.

I think we disagree on the meaning of alphabetical vs. alphanumeric. Regardless, it doesn't sort the way you want.

(EDITED to change sort to asort - the indexation is important.)

 
kdji123

Joined: 2009-05-05
Posts: 24
Posted: Thu, 2010-03-11 22:08

ur right alecmyers the sorting is not in the module inc. i think
it would be better if the module has its own block.
what say u?

or else if u could suggest alternate possibility,

thanks.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2010-03-11 22:22
Quote:
it would be better if the module has its own block.
what say u?

I don't think that would suit most people.

How about this: see the part

Quote:
'text' => 'Download photo(%s x %s)','arg1' => $potentialImage->getWidth(),'arg2' => $potentialImage->getHeight())

What happens if you use a different format string other than %s - maybe something that will pad the number out with spaces at the front then you'd get "<space>150" and "1600" for instance, and they'd sort in the right order. I think you do that by changing %s to %4d, for example. Try it.

 
kdji123

Joined: 2009-05-05
Posts: 24
Posted: Fri, 2010-03-12 18:30

ya alecmyers this works,thanks a lot!.

though i want to separate the links from other modules like favorite or ecard. so guess the only way to do this is to use separate block for Downloadlink.
i will greatly appreciate it if u could suggest that what should be the parameters for module.inc and the callbacks for the module.template.

Regards!

 
diegosanchez

Joined: 2009-12-07
Posts: 54
Posted: Wed, 2010-04-21 07:40

is there a way to get it so that you can specify individual names

such as instead of Download Photo (100 x 75) and Download Photo (3648 x 2736)

you can have Download Thumbnail and Download Original

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2010-04-21 09:55

@diegosanchez: read the posts above from kdji123 about sorting the links in a different order, and refer to the code in the module.inc file. Obviously you can change the code so the links have any name you like.

 
diegosanchez

Joined: 2009-12-07
Posts: 54
Posted: Thu, 2010-04-22 13:01

from the information gathered above i can changed the text displayed, which then changes the entire lot.

what id be looking for would be something conditional.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2010-04-22 14:13
Quote:
what id be looking for would be something conditional.

You can program it however you like.

 
diegosanchez

Joined: 2009-12-07
Posts: 54
Posted: Fri, 2010-04-23 12:57

any help on recreating the script would be great, i cant make heads or tails on whats there at the moment