where are the custom thumbnails

fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Fri, 2005-04-15 22:01

Hello all, thanks for the new feature 'Custom Thumbnail' , it's cool.
But could you tell me where are stored the actual uploaded files ? Or even better, how can I call the file for a given album on a page (not the thumbnail but the original file) ?
Thanks.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Mon, 2005-04-18 04:49

The uploaded files are stored in g2data/plugins_data/modules/thumbnail

fly.cub wrote:
how can I call the file for a given album on a page (not the thumbnail but the original file) ?

Not really sure what you're asking here. Can you elaborate?

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Mon, 2005-04-18 09:59

For each album (as well as nested album), I am going to upload a picture file for the custom thumbnail.
For the uploaded files, I'm thinking of using the following naming convention : albumName_header.jpg

On each album's homepage (i.e. albumBody.tpl), I want to display the corresponding uploaded picture (not the thumbnail) as a banner.
(here's an example in G1 : http://server101.totalchoicehosting.com/~severyn/gallery/aero)

I could use code like this :

<img src="{g->url href="www.myserver.com/g2data/plugins_data/modules/thumbnail/`$nameOfTheAlbum`/_header.jpg"}"/>

For such line of code, what's the correct variable name :$nameOfTheAlbum ?

Or, maybe, there's already a variable which points to the corresponding file, which would spare me from truncating the name with '_header.jpg'.

In this case, the code would look like :

<img src="{g->url href=$pathToCustomPicture}"/>

I hope all this makes sense...
[/code]

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-18 14:22

in layout.inc do this:

GalleryCoreApi::relativeRequireOnce('modules/thumbnail/classes/ThumbnailHelper.class');
list ($ret, $thumbnailImage) = ThumbnailHelper::fetchThumbnail($item->getId());
if ($ret->isError()) {
    return array($ret->wrap(__FILE__, __LINE__), null);
}
if (isset($thumbnailImage)) {
    $layout['headerImage'] = $thumbnailImage->getMemberData();
}

then in your tpl you can do:

{if isset($layout.headerImage)}
  {g->image item=$layout.headerImage image=$layout.headerImage}
{/if}
 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Mon, 2005-04-18 14:58

Thank you Mindless (you're on every thread !).
I get a parse error (unexpected T_STRING) on layout.inc
I am way too ignorant to see if there's a typo in your code, or if it's something else...

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-18 15:33

please look at the code I posted and integrate it appropriately rather than just copy/paste... i'm assuming you have enough understanding of layout.inc so you can find the right place to add that code (ie, somewhere where $layout is available).
and either you can decipher any error msg from php or you'll need to post more detail than "unexpected T_STRING"...

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Mon, 2005-04-18 16:47

It is embarrassing, but no, I don't really understand how layout.inc works, nor do I understand your code (again, I know html & css, that's it).

here are parts of my layout.inc file, so you'll see where I put your code.
The parse error is :
Parse error: parse error, unexpected T_STRING in /home/severyn/public_html/gallery2/layouts/darkglass/layout.inc on line 173

 /**
     * @see GalleryLayout::loadTemplate
     */
    function loadTemplate(&$template, $item) {
	global $gallery;
	$urlGenerator =& $gallery->getUrlGenerator();

	if ($item->getCanContainChildren()) {
	    list ($ret, $params) = $this->fetchParameters($item->getId());
	    if ($ret->isError()) {
		return array($ret->wrap(__FILE__, __LINE__), null);
	    }
	    list ($ret, $bodyFile) = $this->_loadAlbumTemplate($template, $item, $params);
	} else {
	    list ($ret, $params) = $this->fetchParameters($item->getParentId());
	    if ($ret->isError()) {
		return array($ret->wrap(__FILE__, __LINE__), null);
	    }
	    list ($ret, $bodyFile) = $this->_loadSingleTemplate($template, $item, $params);
	}
	if ($ret->isError()) {
	    return array($ret->wrap(__FILE__, __LINE__), null);
	}
 
    $layout =& $template->getVariableByReference('layout');

	/********************* code given by Mindless ***************************/
   GalleryCoreApi::relativeRequireOnce('modules/thumbnail/classes/ThumbnailHelper.class'); 
   list ($ret, $thumbnailImage) = ThumbnailHelper::fetchThumbnail($item->getId()); 
   if ($ret->isError()) { 
     return array($ret->wrap(__FILE__, __LINE__), null); 
    } 
    /********************* end code given by Mindless ***************************/
	
	/* Prepare image frames, if available */
	list ($ret, $imageframe) = GalleryCoreApi::newFactoryInstance('ImageFrameInterface_1_1');
	if ($ret->isError()) {
	    return array($ret->wrap(__FILE__, __LINE__), null);
	}
	if (isset($imageframe)) {
	    $frameIds = array();
	    if ($item->getCanContainChildren()) {
		foreach (array('albumFrame', 'itemFrame') as $key) {
		    if (!empty($params[$key])) {
			$frameIds[] = $layout[$key] = $params[$key];
		    }
		}
	    } else {
		if (!empty($params['photoFrame'])) {
		    $frameIds[] = $layout['photoFrame'] = $params['photoFrame'];
		}
	    }
	    if (!empty($frameIds)) {
		$ret = $imageframe->init($template, $frameIds);
		if ($ret->isError()) {
		    return array($ret->wrap(__FILE__, __LINE__), null);
		}
	    }
	}

	if (is_array($bodyFile)) {
	    return array(GalleryStatus::success(), $bodyFile);
	} else {
	    $template->head('layouts/darkglass/templates/head.tpl');
	    $template->style('templates/layout.css');
	    $template->style('layouts/darkglass/layout.css');
	    return array(GalleryStatus::success(), array('body' => $bodyFile));
	}
    }

    /**
     * Render an album

And at the end of the file :

/* Tell Smarty about everything we've learned */
    /********************* code given by Mindless ***************************/
    if (isset($thumbnailImage)) { 
     $layout['headerImage'] = $thumbnailImage->getMemberData(); 
     }
	/********************* end code given by Mindless ***************************/
	$layout['can'] = $can;
	if (isset($sourceImageViewIndex)) {
	    $layout['sourceImageViewIndex'] = $sourceImageViewIndex;
	}
	$layout['baseUrl'] = GalleryUtilities::convertPathToUrl(dirname(__FILE__));
	$layout['imageViews'] = $imageViews;
	$layout['sourceImage'] = $sourceImage;
	$layout['imageViewsIndex'] = $imageViewsIndex;
	$layout['navigator'] = $navigator;
	$layout['showImageOwner'] = $params['showImageOwner'];

	return array(GalleryStatus::success(), 'layouts/darkglass/templates/singleBody.tpl');
    }
}
?>
 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-18 17:30

1) remove the funny binary characters that got into your layout.inc from your copy/paste.
2) move the "if (isset" block from where you have it now to where you currently have the other block.
3) move the relativeRequireOnce to the top of loadTemplate
4) put 2 copies of the fetchThumbnail and subsequent error check into the getCanContainChildren() if block... one for albums and one for items.. in the album block use $item->getId(), in the item block use $item->getParentId().. that way when you're viewing a photo it will load the header image for the parente album.

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Mon, 2005-04-18 19:54

I still have the same error. I think I followed your directions correctly :

   /**
     * @see GalleryLayout::loadTemplate
     */
    function loadTemplate(&$template, $item) {
    GalleryCoreApi::relativeRequireOnce('modules/thumbnail/classes/ThumbnailHelper.class'); 
	global $gallery;
	$urlGenerator =& $gallery->getUrlGenerator();

	if ($item->getCanContainChildren()) {
	    list ($ret, $params) = $this->fetchParameters($item->getId());
	    if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); }
	    list ($ret, $bodyFile) = $this->_loadAlbumTemplate($template, $item, $params);
		list ($ret, $thumbnailImage) = ThumbnailHelper::fetchThumbnail($item->getId()); 
        if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } 
	} else {
	    list ($ret, $params) = $this->fetchParameters($item->getParentId());
	    if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); }
	    list ($ret, $bodyFile) = $this->_loadSingleTemplate($template, $item, $params);
		list ($ret, $thumbnailImage) = ThumbnailHelper::fetchThumbnail($item->getParentId());
	    if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } 
	}
	if ($ret->isError()) {
	    return array($ret->wrap(__FILE__, __LINE__), null);
	}
    $layout =& $template->getVariableByReference('layout');
	 if (isset($thumbnailImage)) { 
     $layout['headerImage'] = $thumbnailImage->getMemberData(); 
     }
	
	/* Prepare image frames, if available */
	list ($ret, $imageframe) = GalleryCoreApi::newFactoryInstance('ImageFrameInterface_1_1');
 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-04-18 22:34

just move the fetchThumbnail/error-checks above the _loadAlbumTemplate/_loadSingleTempate calls and you'll be done (so the error check below that if block will still work)

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Tue, 2005-04-19 12:00

OK, no more error message, but the img doesn't come up. I get the following html code :

<img src="http://www.myserver[edited].com/g2data/plugins_data/modules/thumbnail//_header.jpg?g2_GALLERYSID=b0a7329b0b5934ec30df49bfd91e0b8d"/>

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-04-19 14:24

1) manually retype the section you have commented in layout.inc (setting 'headerImage'), but don't comment out this time.
2) delete the commented lines, which include some binary characters
3) manually retype the headerImage section in your albumBody.tpl
4) delete the current headerImage section which has a binary character

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Tue, 2005-04-19 16:12

it's getting better, but still no picture : the img block shows, as well as the alt text, but not the jpg.

the html source is :
<img src="http://www.myserver.com[edited]/gallery2/main.php?g2_view=core:DownloadItem&amp;g2_itemId=201&amp;g2_serialNumber=1&amp;g2_GALLERYSID=d5ab8a6c8941814d17fcac5bb3e353bf" width="750" height="236" alt="chambord_header.jpg"/>

thank you for being so patient.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-04-19 17:11

1) probably a good idea to use <!-- and --> around html comments.. i'm not sure, but the extra --'s may confuse some browsers

2) oops, I forgot the full size custom thumbnail file is only given permission for Site Admins when it is created.. if you want to use it in this way you need to add additional permissions.. there is no UI for this.

you can edit your modules/thumbnail/classes/ThumbnailHelper.class function addItem, where it gets id.adminGroup change it to id.everybodyGroup and then any new custom thumbnails you add will have public access.. you'll need to remove and re-add your existing custom thumbs.

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Tue, 2005-04-19 22:04

We're done ! It works !

Thanks again for all your help and patience. Now I'll try to finish my custom layout and post it as soon as it's ready.

Didn't even have to remove and recreate the existing custom thumbs.

Take care.

:cry:
[EDIT]
Scratch that...
I just went back on the pages and the images are no longer there. I tried to remove and recreate custom thumbs but I get a Fata error :

Quote:
Fatal error: Call to undefined function: convertmimetoextension() in /home/severyn/public_html/gallery2/modules/thumbnail/classes/ThumbnailHelper.class on line 202

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-04-19 22:29

1) what change did you make to ThumbnailHelper.class? I still see id.adminGroup on your site.
2) what's your G2 version? the latest ThumbnailHelper.class doesn't have that convertExtensionToMime call.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-04-19 22:37

you appear to have a mix of old and new files on your site.. use the manifest check in upgrader step 2 to make sure you have a valid codebase.

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Wed, 2005-04-20 05:43

I had B2 (first release -- 0.9.10) installed. Just upgraded to current B2 (0.9.14) and edited ThumbailHelper.class via cpanel.
It now works.

Just a quick question : it seems I can't select a Custom Thumbnail for my main gallery (the home page). I can create another layout just for this page (without the custom thumbnail code). Would you have another trick ?

Re. the mixed files : I'm not sure if I do the right thing : I usually ftp the tar.gz file on my server, extract it with cpanel and then run the upgrader.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2005-04-20 14:27

if you remove the $item->getParentId() > 0 check from function isAppropriate in modules/thumbnail/CustomThumbnailOption.inc then the form will appear even for the root album.. (normally we hide it since you can't see a thumbnail for the root album anywhere...)

yup, that's the right way to upgrade..

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Thu, 2005-04-28 13:59

Just a quick note to Mindless : I'm almost done with my custom G2, thanks to you !
Here it is :
http://www.severyns.com/gallery2

I still need to work on some details and the admin layouts, but I got what I wanted. I'll be glad to post the files when it's done.

Cheers.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-04-28 14:11

fly.cub, showing an image in the album description is a good idea, looks great, eg. http://www.severyns.com/gallery2/main.php?g2_view=core:ShowItem&g2_itemId=395

did you just add html img code to the description field?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2005-04-28 14:42

valiant, no.. the tpl is referencing the ThumbnailImage of the custom thumbnail for the album (the ThumbnailImage has the image that was uploaded in its original size, which is used as the source image for the album thumbnail.. I helped fly.cub to access this object directly....)

 
fly.cub

Joined: 2005-03-31
Posts: 30
Posted: Thu, 2005-04-28 19:42

credit for the idea should go to http://www.frommel.net/gallery : it's a G1 design.
The author never shared his G1 templates so I started from scratch in G2.

 
draco2002

Joined: 2003-04-28
Posts: 70
Posted: Tue, 2006-03-07 19:08

This works in 2.1 rc1 as long as you keep with the new api changes like

$ret->isError()
changes to
$ret

ps. Thanks Mindless for the great help.

|| G1 Hosting | Custom Theming | Donate to Gallery ||

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-03-07 20:59

there is a mention of the permissions thing above... http://gallery.menalto.com/node/29086#comment-104201