Forums / Setup & design / fetching images from media library

fetching images from media library

Author Message

nicholas king

Wednesday 01 December 2010 6:00:09 am

i am having trouble getting images from the media library using a fetch node.

any ideas?

Thanks

{foreach $node.object.data_map.images.content.relation_list as $relatedData}
<span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span>{set $imagenodes=fetch('content','node', hash(node_id,$relatedData.node_id))}
<span class="Apple-tab-span" style="white-space:pre"> </span>{node_view_gui view="images" content_node=$imagenodes}
{/foreach}

Ivo Lukac

Wednesday 01 December 2010 6:31:53 am

Hi

Check if anonymous has permissions to read from Media.

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

nicholas king

Wednesday 01 December 2010 6:41:01 am

Hello Ivo, i have given annonymous unlimited access to read content but this returns nothing

$imagenodes seems to be empty, any other ideas.

Thanks

{if $node.object.data_map.images.has_content}
<h4 style="margin-top:10px;">Related Images</h4>    
{foreach $node.object.data_map.images.content.relation_list as $relatedData}     
{set $imagenodes=fetch('content','node', hash(node_id,$relatedData.node_id))}     
{$imagenodes|attribute(show)}          
{node_view_gui view="image" content_node=$imagenodes}    
{/foreach}   
{/if}

Ivo Lukac

Wednesday 01 December 2010 7:03:22 am

"

Hello Ivo, i have given annonymous unlimited access to read content but this returns nothing

$imagenodes seems to be empty, any other ideas.

Thanks

{if $node.object.data_map.images.has_content}
<h4 style="margin-top:10px;">Related Images</h4>    
{foreach $node.object.data_map.images.content.relation_list as $relatedData}     
{set $imagenodes=fetch('content','node', hash(node_id,$relatedData.node_id))}     
{$imagenodes|attribute(show)}          
{node_view_gui view="image" content_node=$imagenodes}    
{/foreach}   
{/if}
"

You are setting a variable which is not defined. You should def the $imagenodes before the loop, or def and undef it in the loop, or use fetch directly:

{node_view_gui view="image" content_node=fetch('content','node', hash(node_id,$relatedData.node_id))}

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

nicholas king

Wednesday 01 December 2010 7:16:36 am

Hello Ivo,

Thanks very much for your help. As suggested by you this seems to be the solution.

Thanks

Nicholas

{node_view_gui view="image" content_node=fetch('content','node', hash(node_id,$relatedData.node_id))}