Gallery and own upload folder and reselect images?

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

Gallery and own upload folder and reselect images?

Postby Harm10 » Sun Sep 27, 2009 3:34 pm

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?
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Gallery and own upload folder and reselect images?

Postby rabbeltje » Mon Sep 28, 2009 6:39 am

i'd like both of these options as well!
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: Gallery and own upload folder and reselect images?

Postby xzjia » Wed Sep 30, 2009 2:49 am

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.
xzjia
 
Posts: 110
Joined: Tue Dec 11, 2007 6:26 pm

Re: Gallery and own upload folder and reselect images?

Postby Harm10 » Wed Sep 30, 2009 4:59 am

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....... ;)
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Gallery and own upload folder and reselect images?

Postby rabbeltje » Wed Sep 30, 2009 8:53 am

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?
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: Gallery and own upload folder and reselect images?

Postby Harm10 » Wed Sep 30, 2009 10:09 am

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?
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Gallery and own upload folder and reselect images?

Postby rabbeltje » Wed Sep 30, 2009 11:21 am

sorry, for fancybox :)

(please keep in mind that i am not exactly that well-educated in php ;) so small children-language works best ;))
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: Gallery and own upload folder and reselect images?

Postby Harm10 » Wed Sep 30, 2009 7:06 pm

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:
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Gallery and own upload folder and reselect images?

Postby rabbeltje » Thu Oct 01, 2009 7:26 am

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!
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: Gallery and own upload folder and reselect images?

Postby Harm10 » Thu Oct 01, 2009 11:09 am

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
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Next

Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 4 guests

cron