solved Get an image for a playlist item

Nmaster88
Nmaster88
@nmaster88
8 years ago
94 posts
It may be a little confuse for me to explain, but i want to do the following:

In my custom skin in the page of jrPlaylist_item_list
there i have a list with the playlists that have been created for the user.
But i want, to display for each playlist the image of the first song of that playlist.

I've been thinking about using the img element and finding the path to the image, where i think i can get the id from playlist_list.
But has i have been thinking i think i just have to call
{jrCore_module_function function="jrImage_display" ...}

What is the easiest way for me to do that?
para_apagar.jpg
para_apagar.jpg  •  118KB


updated by @nmaster88: 06/18/16 01:24:40PM
michael
@michael
8 years ago
7,715 posts
The code you want for the image is:
{jrCore_module_function function="jrImage_display" module="jrAudio" type="audio_image" item_id=(THE ITEM ID HERE) size="small" crop="auto" class="iloutline"}

So you need to iterate over that json encoded array. Normally I would expect that that playlist_list would have been decoded by the module itself. unless its in a list function.

So there are probably a couple of ways to decode it, like passing it to a custom smarty function and decode it and format it there:

Docs: "Defining your own smarty function"
https://www.jamroom.net/the-jamroom-network/documentation/development/1569/defining-your-own-smarty-function

or you might be able to decode it directly in the templates:
{foreach $_items as $item}
{$playlist = json_decode($item.playlist_list,true)}
 {foreach $playlist as $id => $position}
  {* show the image *}
   {jrCore_module_function function="jrImage_display" module="jrAudio" type="audio_image" item_id=$id size="small" crop="auto" class="iloutline"}
 {/foreach}
{/foreach}

something like that.
Nmaster88
Nmaster88
@nmaster88
8 years ago
94 posts
Thanks that helped a lot.

Because its an array inside an array i solved like this:

                        {$playlist = json_decode($item.playlist_list,true)}
                        {foreach $playlist as $id => $position}
                            {foreach $position as $id1 => $position1}
                                {if $position1==0}
                                    {jrCore_module_function function="jrImage_display" module="jrAudio" type="audio_image" item_id=$id1 size="medium" crop="width" class="dker" alt="artist photo"}
                                {/if}
                            {/foreach}
                        {/foreach}

Tags