[SOLVED] how to get the thumbnail url of the resized pic on [photo.tpl] page

mexicoshaun

Joined: 2007-06-21
Posts: 15
Posted: Fri, 2012-06-22 11:53

Hi all, would anyone be so kind as to consider this for me,

re: valiant's comments here http://gallery.menalto.com/node/60319 [Grab hi-res pic and thumbnails URL's]
- I have followed valiant's instructions but can't get the thumbnail url of the resized image to display properly.

We have G2 set up so that you must login to see full size/ resized images. I am trying to implement the facebook 'like' button and the 'open graph meta tags', specifically 'og:image', in order to tell facebook the url of the image to show on facebook user's timelines when they like the [photo.tpl] page. I can show the url of the actual item [ie the resized photo] with:
<meta property="og:image" content="http://www.hen-night.org{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.item.id`"}" />

- which works fine technically except that because facebook is not logged in to G2 it can't locate the image - so i really need to tell it the thumbnail location instead, as thumbnails are not protected.

My modified function in theme.inc looks like:

====================================================================

function showPhotoPage(&$template, $item, $params) {
$dataTypes = array('owner', 'parents', 'systemLinks', 'itemLinks', 'permissions',
'itemLinksDetailed', 'itemNavigator', 'imageViews');
if (!empty($params['showMicroThumbs'])) {
$dataTypes[] = 'navThumbnails';
}
$ret = $this->loadCommonTemplateData($template, $item, $params, $dataTypes);

/**
* valiants additions start
*/
$theme =& $template->getVariableByReference('theme');
list ($ret, $thumbMap) = GalleryCoreApi::fetchThumbnailsByItemIds(array($theme['item']['id']));
$theme['item']['thumb'] = (array)array_shift($thumbMap);
/**
* valiants additions end
*/

if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
return array(null, 'theme.tpl');
}

=============================================================================

and i have:

<meta property="og:image" content="{g->url arg1='view=core.DownloadItem' arg2='itemId=`$theme.item.thumb.id`' forceFullUrl=true htmlEntities=false}" />,
(in a conditional block for the head when photo page in theme.tpl)

But the link appears as:
http://www.hen-night.org/main.php?g2_view=core.DownloadItem&g2_itemId=%60%24theme.item.thumb.id%60

rather than:
http://www.hen-night.org/d/1177690-3/DSCF2995.JPG

For some reason it is not passing the item id correctly.

Am I doing something wrong or is it an issue with versions? [the post i found was 5 years ago!] perhaps there is a different way to do this?

Gallery URL = http://www.hen-night.org/main.php
Gallery version = 2.3.2 core 1.3.0.2
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.3.10 apache2handler
Webserver = Apache/2.2.3 (CentOS)
Database = mysqli 5.5.22-cll, lock.system=database
Toolkits = ImageMagick, NetPBM, Gd, Thumbnail
Acceleration = none/1209600, none/1209600
Operating system = Linux server50829.uk2net.com 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:23:01 EDT 2011 i686
Default theme = adonis
gettext = enabled
Locale = en_GB
Browser = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1
Rows in GalleryAccessMap table = 829
Rows in GalleryAccessSubscriberMap table = 170421
Rows in GalleryUser table = 43324
Rows in GalleryItem table = 170170
Rows in GalleryAlbumItem table = 1438
Rows in GalleryCacheMap table = 0

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2012-06-22 12:42

use $theme.item.id instead of $theme.item.thumb.id

-s

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Fri, 2012-06-22 14:32

Valiant's code is still valid for v2.3.2 except that you most likely already have "$theme =& $template->getVariableByReference('theme');" under your showPhotoPage function and should not add it again really. This is not critical though.

Try copying and pasting this in directly ...

<meta property="og:image" content="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.item.thumb.id`"}" />

--
dakanji.com

 
mexicoshaun

Joined: 2007-06-21
Posts: 15
Posted: Fri, 2012-06-22 15:10

thanks guys, dayo, copying and pasting your code solved the problem, v grateful :)