Page 1 of 3

Gallery and own upload folder and reselect images?

PostPosted: Sun Sep 27, 2009 3:34 pm
by Harm10
I'd like to have [[ gallery ]] it's own upload folder (so separated from the general one in the config).
Is this possible?

I'd also like to have the option to select already uploaded images in the edit gallery (similar to userimage).
Is this possible?
This last option would be useful to just ftp a lot of images in the folder and then just to select them. Or does this pose a problem with thumbnails?

Re: Gallery and own upload folder and reselect images?

PostPosted: Mon Sep 28, 2009 6:39 am
by rabbeltje
i'd like both of these options as well!

Re: Gallery and own upload folder and reselect images?

PostPosted: Wed Sep 30, 2009 2:49 am
by xzjia
Hear hear.

Also would like the ability to get proper caption for Fancybox / Thickbox.

Something basic such as converting "/23-09-2009/my_image.jpg" -> "My Image" would be good enough.

I guess it is simply find the file extension and snip it, find the underscore and replace with space, and also parse the string from the back (uh, how?) until it hits the slash "/" and stop. Finally capitalize what's left.

I'm trying to learn smarty tags, but I have a hard time reading through their docs, arghhh someone must know how.

Re: Gallery and own upload folder and reselect images?

PostPosted: Wed Sep 30, 2009 4:59 am
by Harm10
This can already be done using standard php functions......
Code: Select all
$caption = basename($filename);
$caption = str_replace('.jpg', '', $caption);
$caption = str_replace('_', ' ', $caption);
I coded something similar in snippet_media.php where no captions are shown at all! So you could try this....... ;)

Re: Gallery and own upload folder and reselect images?

PostPosted: Wed Sep 30, 2009 8:53 am
by rabbeltje
xzjia wrote:Hear hear.

Also would like the ability to get proper caption for Fancybox / Thickbox.

Something basic such as converting "/23-09-2009/my_image.jpg" -> "My Image" would be good enough.

I guess it is simply find the file extension and snip it, find the underscore and replace with space, and also parse the string from the back (uh, how?) until it hits the slash "/" and stop. Finally capitalize what's left.

I'm trying to learn smarty tags, but I have a hard time reading through their docs, arghhh someone must know how.


now wouldn't that be something! i think i've already asked about it on this forum before but i think back when it wasn't possible.

@harm10: exactly where would i have to put that code to (try to) make it work?

Re: Gallery and own upload folder and reselect images?

PostPosted: Wed Sep 30, 2009 10:09 am
by Harm10
rabbeltje wrote:@harm10: exactly where would i have to put that code to (try to) make it work?

For snippet_media.php or for fancybox?

Re: Gallery and own upload folder and reselect images?

PostPosted: Wed Sep 30, 2009 11:21 am
by rabbeltje
sorry, for fancybox :)

(please keep in mind that i am not exactly that well-educated in php ;) so small children-language works best ;))

Re: Gallery and own upload folder and reselect images?

PostPosted: Wed Sep 30, 2009 7:06 pm
by Harm10
I assume you want this for fancybox when using it in [[gallery]]?
Because for [[popup]] you can use parms description and alt. For the extra image field you can use also description (although I think that one doesn't uses fancybox.
But I can imagine that there are probably a lot of instances where you want a filename to be somewhat nicely shown.

For this I suggest (hopefully Hans will concur with this) a new function in lib.php:
Code: Select all
/**
 * Tries to format the filename in a nice way
 * @param string $filename
 * $return string
 */
function formatfilename($filename) {
    if($filename != ""){
       $filename = basename($filename);
       $filename = removeextension($filename);    
       $filename = str_replace('_', ' ', $filename);
    }
    return $filename;
 }
This takes care of removing any directory information, the extension and replacing underscores with spaces. This function can be expanded to your liking.

Then I suggest the following change to hook_gallery.php (the second line is new)
Code: Select all
$this_output = str_replace('%filename%', $image, $this_output);
$this_output = str_replace('%nicefile%', formatfilename($image), $this_output);
And the usage of [[gallery]] like this (%nicefile% is new)
Code: Select all
[[gallery popup="fancybox"]]
   <a href='%imageurl%%filename%' class="fancybox" title="%nicefile%" rel="gallery-%uid%" >
   <img src="%pivotxurl%includes/timthumb.php?src=%filename%&amp;w=106&amp;h=80&amp;zc=1" alt="%nicefile%" />
   </a>
[[/gallery]]

Was this the general idea? :roll:

Re: Gallery and own upload folder and reselect images?

PostPosted: Thu Oct 01, 2009 7:26 am
by rabbeltje
i've tried the things you said and it does now give the alt with a nice filename, except the fancybox no longer works :( it just opens the image instead of a hovering fancybox.

*edit: solved it! the error was caused by this part:
Code: Select all
[[gallery popup="fancybox"]]


i left that part out and just used the rest of your code and it works wonderfully! thanks a million!

Re: Gallery and own upload folder and reselect images?

PostPosted: Thu Oct 01, 2009 11:09 am
by Harm10
rabbeltje wrote:*edit: solved it! the error was caused by this part:
Code: Select all
[[gallery popup="fancybox"]]


i left that part out and just used the rest of your code and it works wonderfully! thanks a million!

This parm was introduced by one of the recent revisions (http://pivot-weblog.svn.sourceforge.net/viewvc/pivot-weblog?view=rev&revision=2150)to bypass the comment popup line when using gallery on pages. So you better upgrade to that level I think.
Look at this discussion: http://forum.pivotx.net/viewtopic.php?f=13&t=1042&start=10