Specify an external URL for a thumbnail image


(Lauren) #1

Matrix Version: v5.3.3.0

Hello,

I have been asked to make it possible to add an external url to a thumbnail asset.

Currently the thumbnail asset looks like this in the parse file:

  <MySource_AREA id_name="page_banner" design_area="show_if">
      <MySource_SET name="condition" value="keyword_regexp"/>
      <MySource_SET name="condition_keyword" value="globals_asset_metadata_banner_image_id"/>
      <MySource_SET name="condition_keyword_match" value="[0-9]+" />
          <MySource_THEN>
          <img class="page_banner" src="%globals_asset_metadata_banner_image_id^as_asset:asset_url%" alt="Page banner" width="100%" />
          </MySource_THEN>
  </MySource_AREA>

As you can see there is no a tag wrapped around the image. Any advice for adding this functionality very much appreciated.

Thanks


(Bart Banda) #2

Where is the URL to the external URL going to be sourced from? From another metadata field? Or do you just want to user the URL of the image as the href value for the link?

Btw, you could also rewrite that section using just a keyword, something like:

%globals_asset_metadata_banner_image_id^as_asset:asset_contents_raw%

Using asset_contents_raw on an image asset will print it as an img tag.


(Lauren) #3

Thank you for you quick reply Bart,

Yes, it would be great if the external URL could be sourced from another metadata field. If you could list the steps to do this and code for parse file please.

Also does Squiz Matrix have more in depth developer docs located online somewhere?

Thanks again


(Bart Banda) #4

Ok, so the best way to do this is actually to use a nested content design area and nest in a standard page.

On the standard page, set the display type to Raw HTML so that you get a code editing interface, and enter something like this into it:

%begin_globals_asset_metadata_banner_image_id%
   <a href="%globals_asset_metadata_url%">
      %globals_asset_metadata_banner_image_id^as_asset:asset_conten_raw%
   </a>
%end_globals%

This is where you are using the asset metadata value as the URL for the that wraps the img tag.

There is an online manual for all of this here:
https://matrix.squiz.net/manuals


(Lauren) #5

This is brilliant Bart!! Thanks very much