<![CDATA[ TV galleryitem: extract image path & description? - My Forums]]> https://forums.modx.com/thread/?thread=50588 <![CDATA[Re: TV galleryitem: extract image path & description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-534643 http://forums.modx.com/thread/73571/using-galleryitem-with-getresources-produces-duplicate-images-in-modx-revolution#dis-post-534644]]> full trucker Nov 21, 2015, 12:55 AM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-534643 <![CDATA[Re: TV galleryitem: extract image path & description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-461655
@juliebug thanks!

Quote from: Shopcoop at Feb 09, 2012, 06:02 AM
Hi Trying to do the same thing. This solution works but in displaying multiple posts with TV gallery items it seems to only want to display the last of the TVs. Is there a better solution to this?

@Shopcoop try like this:

[[GalleryItem? &id=`[[getPicId? &imageTV=`[[+image]]`]]` &thumbHeight=`120` &thumbQuality=`100` &thumbWidth=`176` &thumbZoomCrop=`1`]]
<a href="[[~[[+id]]? &scheme=`full`]]"><img src="[[+galitem.thumbnail]]" alt="[[+pagetitle]]" title="[[+pagetitle]]" /></a>

It works in my getResources smiley
]]>
desbr1nger Apr 04, 2013, 07:41 AM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-461655
<![CDATA[Re: TV galleryitem: extract image path & description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-411192 Shopcoop Feb 09, 2012, 12:02 AM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-411192 <![CDATA[Re: TV galleryitem: extract image path &amp; description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296172
Thanks for this thread. I was having the same problem as others. Using the GalleryItemTV is great but for output it is not flexible in situations where you want to show a thumbnail image or you want to customize the output to include the description. The best way is to use the GalleryItem snippet, but you need the ID of the gallery item as discussed here: http://modxcms.com/forums/index.php/topic,55962.0.html.

I’ll show the example of how I solved this. I’m displaying news items on my home page with a link to read the full item. If there is an image associated with the item, a thumbnail of that image is displayed.

Assumptions: You are using this method for associating an image with a resource: http://rtfm.modx.com/display/ADDON/Gallery.Setting+Up+the+GalleryItem+TV. In this example the image template variable is named "image".

1. On the Home page, the getResources call:
<div class="header bot-bdr">
<h3>News & events</h3>
<!-- / header --></div>
<div class="section">
[[!getResources? 
  &parents=`207` 
  &tpl=`tpl-news-intro` 
  &sortby=`publishedon` 
  &includeTVs=`1`
  &sortdir=`desc`
  &limit=`4`
]]
<!-- / section --></div>

Notice that I do not include the processTVs parameter.

2. The "tpl-news-intro" chunk:
<!-- news-intro template -->
<div class="inner news-intro">
[[+tv.image:notempty=`
<div class="img-wrap">
[[!GalleryItem? &id=`[[!getPicId? &imageTV=`[[+tv.image]]`]]` &thumbWidth=`100`]]  

<a href="[[+galitem.image]]" rel="enlarge">
    <img src="[[+galitem.thumbnail]]" alt="[[+galitem.name]]" />
</a>

</div>
`]]
... continues (not relevant)


This is a bit tricky to follow.. this chunk is used by getResources but to display the image we call the "getPicId" snippet inside of the "GalleryItem" snippet. "getPicId" gives us the image that is stored in the "image" template variable. Then we pass some parameters to "GalleryItem" (thumbWidth) and put the placeholders below the "GalleryItem" snippet to format our output as needed.

3. The "getPicId" snippet:
<?php
$obj=json_decode($imageTV);
return $obj->gal_id;


(I’m sure there are ways to foolproof the code above, please advise!)

The gallery item data is stored in JSON format. This PHP function reads it and allows you to extract the info you are looking for by key name... handy! In this case, we just need to extract the ID of the gallery item and pass it to GalleryItem where we have full control over display.

I hope this is helpful.]]>
juliebug Dec 18, 2010, 06:12 PM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296172
<![CDATA[Re: TV galleryitem: extract image path &amp; description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296171
phpthumbof seems to change the contents of the string (as in gal_filename disappears) - just something to be aware of.

Hope it helps]]>
damsonsky Dec 11, 2010, 04:22 AM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296171
<![CDATA[Re: TV galleryitem: extract image path &amp; description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296170
{"gal_id":2,"gal_name":"Gall name","gal_filename":"2010/12/image.jpg","gal_description":"picture","gal_mediatype":"image","gal_createdon":"2010-12-09 23:51:50","gal_createdby":1,"gal_active":1,"gal_duration":"","gal_streamer":"", "gal_watermark_pos":"tl","gal_image_width":300,"gal_image_height":100,"gal_image_type":2, "gal_src":"http://site/dir/images/2010/12/image.jpg","gal_orig_width":300,"gal_orig_height":100,"gal_album":"1","gal_watermark-text":"","gal_watermark-text-position":"BL","gal_other":"","gal_rotate":0,"gal_sizer":100,"gal_cropCoords":"",
"gal_cropTop":0,"gal_cropRight":0,"gal_cropBottom":0,"gal_cropLeft":0}

...same as the OP’s.

http://modxcms.com/forums/index.php/topic,55962.0.html (Another topic on the same issue) though this OP wanted to just output the url. I’m hoping for a complete img tag but with a simple url which I think the OP here wants... apologies if I hijacked your post s1Mon.]]>
damsonsky Dec 10, 2010, 01:33 PM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296170
<![CDATA[Re: TV galleryitem: extract image path &amp; description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296169
I’m confused about this too. I’ve a template variable (imageVar) with both input and output set to GalleryItem.

Outputting via [[*imageVar]] on a template results in a well formed <img /> tag, but with a very messy url involving src=" ...connector.php?action=etc..." where I expected to see the system setting gallery.files_url (src="/images/image.jpg").

- Can I not access the simple direct url via the template var in someway? (Been looking into this and not seeing it, I’m still such a newby at MODx)

Outputting via [[+tv.imageVar]] in a chunk produces the string posted by the OP, no <img /> tag at all.

- Are you saying Sunwukung that we should abandon using a template var completely?
- I’ve just had a play and it’s not hitting me between the eyes how I reference the template variable via the gallery syntax. I said this was confusing me.

I’ve read that the gallery thing is only a "temporary solution" so does this wheel need inventing?

Thanks for opinions.]]>
damsonsky Dec 10, 2010, 01:20 PM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296169
<![CDATA[Re: TV galleryitem: extract image path &amp; description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296168 I’ve just been working on something like this myself - I chose to change the OUTPUT of the TV to match the input, so it will display the gallery item automatically]]> sunwukung Nov 17, 2010, 06:24 AM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296168 <![CDATA[TV galleryitem: extract image path &amp; description?]]> https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296167
I’m just playing around with some image effects and to enable the user to upload a new picture to be displayed, I’ve created a TV named "homepic1". Now, if I choose the TV input type of "galleryitem", the user can comfortably browse the galleries and chose an image. Perfect.

Now, calling the TV via [[*homepic1]] will result in the following output:

gal_src":"url/sand_4.jpg","gal_id":12,"gal_name":"","gal_description":"","gal_image_width":594,"gal_image_height":465,"gal_orig_width":594,"gal_orig_height":465,"gal_album":"2","gal_watermark-text":"","gal_watermark-text-position":"BL","gal_other":"","gal_rotate":"0","gal_sizer":100,"gal_cropCoords":"","gal_cropTop":0,"gal_cropRight":0,"gal_cropBottom":0,"gal_cropLeft":0}" 


However, I just need the URL and the Title of the image to use with <img src="[[*homepic1]]" />!

Is this somehow possible with the TV input type of galleryitem? I could still change it to ’file’, but that would be much less comfortable.

Thanks for any help!]]>
s1Mon Oct 01, 2010, 08:56 AM https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description#dis-post-296167