Displaying a thumbnail with a metadata field in an asset listing


(Barb Kempnich) #1

I have an asset listing that's grouped by the values available in a metadata selection field. My asset listing displays these options as headings for the group listings. I'd like to display a small icon alongside each of those headings (a different one for each field). Is this possible?


(Bart Banda) #2

Hey Barb, can you post what the format is of your group type format? 

 

Where would the icon data come from? Each grouping value? Or would it be the same icon for all groups?


(Barb Kempnich) #3

Hi Bart,

 

Not sure what you mean by 'format of your group type format'.

 

For group format I've just got this at the moment: %group_name%

%group_listing%

What I'd like is to be able to display a small thumbnail alongside each group name. These don't exist yet as I wanted to find out if there's a way to associate a different one with each of the group names (which as I said, are metadata options).


(Tim Davison) #4

Assuming the group names are based on a single metadata field value, and assuming these values a pre-defined (e.g. a select metadata field) you would do something like this:

<h2>
  %asset_metadata_yourField^eq:value1:<img src="./?a=xxx" />%  <!-- icon for value 1 -->
  %asset_metadata_yourField^eq:value2:<img src="./?a=xxx" />%  <!-- icon for value 2 -->
  %asset_metadata_yourField^eq:value3:<img src="./?a=xxx" />%  <!-- icon for value 3 -->
  %asset_metadata_yourField% <!-- the actual value -->
</h2>
%group_listing%

In the above, each of the keyword replacements using ^eq happens separately.  If the value is not equal then nothing prints out, so only one of the them should print.  Downside to this approach is, of course, that you have a finite enumeration.  I.e. it will not handle dynamic inputs.  E.g. a select metadata field, is ok.  You know exactly what values are possible.  A multiple text field, not possible, as the exact values could be anything.

 

(Also, instead of using actual image tags you could use classnames instead and use :before/:after psueudos with icon glyphs, for example).

 

Unless I've misunderstood what you're trying to do.


(Barb Kempnich) #5

Thanks Tim - you haven't misunderstood at all. This is exactly what I was after.


(Barb Kempnich) #6

Unfortunately this isn't giving me a result. Neither the field values nor the icons are displaying.

 

Here's my code:

<h2>
%asset_metadata_EzyReg^eq:Boating:<img src="./?a=35172" />%
%asset_metadata_EzyReg^eq:Licences:<img src="./?a=33387" />%
%asset_metadata_EzyReg^eq:Permits:<img src="./?a=35697" />%
%asset_metadata_EzyReg^eq:Personal details:<img src="./?a=35707" />
%asset_metadata_EzyReg%
</h2>
%group_listing%
 
The display doesn't show either the icon or the filed option as an H2, just the list of assets in each group.
 
Am I missing something?

(Tim Davison) #7

Ah, right you are.  Sorry, my bad.

 

Ok, so I'm assuming to get the group you are grouping by %asset_metadata_EzyReg% (on the grouping screen).  Then in the group format change it to:

<h2>
  %group_name^eq:Boating:<img src="./?a=xxx" />%
  %group_name^eq:Licenses:<img src="./?a=xxx" />%
  ... etc ...
  %group_name%
</h2>
%group_listing%

(i.e. use keyword group_name instead of asset_metadata.)

 

Same principle applies, when you group by a metadata field the group name takes on the value of the metadata field.  Again, sorry for leading you astray.


(Barb Kempnich) #8

I tried that and I get the group name displaying, but not the image.


(Tim Davison) #9

What version of Matrix are you using?  I know not all keyword modifiers work in all contexts for all versions of Matrix.  I've done a quick test and the above approach is working fine for me.

 

Did you look at the source code returned?  Change the image code to simple yes/no and see if that render.  That will tell you whether the keyword is not working or some other syntax error.


(Barb Kempnich) #10

Thanks Tim - all good now.