copy images

SirSiggi

Joined: 2012-11-29
Posts: 10
Posted: Sun, 2012-12-02 16:55

I'm trying to copy images from one album to another, but as it seems I don't quite understand the way Gallery does such things. As for now there seems to be no module that has implemented copying images. Or does anyone know a module that already has this functionality?

What I want is pretty simple: I've got a list of image-ids and want to copy them physically to another album. There has to be no connection to the original.

Can anyone give me a hint how to do this? Any code I can look up as a reference how Gallery creates images? Thank you in advance.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2012-12-02 18:32

There is no module to do this in G3. G2 has this feature if such a feature is that important.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
SirSiggi

Joined: 2012-11-29
Posts: 10
Posted: Sun, 2012-12-02 20:32

Ok, I'm as far as being able to copy images. Here is what I do: http://pastebin.com/nPtnr6vr

But I've got a problem I couldn't figure out yet. For some of the copied pictures the system is not able to retrieve a thumb_width and thumb_height. Because of this $child->has_thumb(); in the view which displays the images fails and the thumbnails are missing. The images itself work just fine.

I couldn't figure out where these fields are set. Where do these fields come from? How can I check, why they are not set for some of the images (because for some they are and the thumbnails are shown).

 
SirSiggi

Joined: 2012-11-29
Posts: 10
Posted: Tue, 2012-12-04 14:27

Has no one ever worked on how the system fetches the information about thumb_width and thumb_height? Because I couldn't find
a solution until now. If anyone has any idea, a little hint, I would be really graceful. Thanks.

 
spags

Joined: 2010-03-26
Posts: 120
Posted: Thu, 2012-12-06 07:32

Thinking of a possible workaround, maybe it would be a good idea to set the dirty flag for the thumbnail in your copy process before your final save. I may be looking in the wrong place, but take a look at modules/gallery/models/item.php in the __construct function and see what it does when creating a new item.

 
SirSiggi

Joined: 2012-11-29
Posts: 10
Posted: Sun, 2012-12-23 12:48

Thanks for the hint, but sadly it didn't work. What worked was setting the thumb_with, thumb_heigt, resize_with, resize_height manually.

My module is more or less a dirty hack, but as soon as it's ready to be deployed I will publish it.

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sun, 2012-12-23 15:03

Not sure where you're running into difficulty. The pastebin code doesn't include any reference to the thumb dimensions; did I overlook it?

You've tried using $item->thumb_width and $item->thumb_height?

Worst case, the info is also stored in the db items table and would be accessible with a db query.

Note sure what you've tried and what file you tried it in, but hope that helps.