1

We're having to change up a template to pull in images from our Portfolio based on a field in a Data Extension that matches the Portfolio Image External Key, so I'm giving the AMPscript function Image(1,2) a shot. It works great for pulling in an image with just the External Key, but I am not seeing any way to alter the size of the image once it has been brought in.

The function actually pulls in the the entire opening and closing img tag, so it seems as though we need a way to manipulate this return to add in a height and width tag.

Documentation: http://help.marketingcloud.com/en/documentation/ampscript/ampscript_syntax_guide/content_ampscript_functions2/image2/

All help is appreciated, thank you.

3

I would use the Image() AMPscript function, but manipulate it using the Replace() function to insert the required height and width. Here's an example (where email_banner is the external key of the Portfolio item):

%%[
var @img, @displayImg
set @img = Image('email_banner')
set @displayImg = Replace(@img,' src','width="100" height="100" src')
]%%

%%=v(@displayImg)=%%
  • This is likely the best way to get around the limitations - you could store the width and height part inside the DE as well to help remove the need for manual coding on the email itself. – Gortonington Jan 9 '17 at 13:40
  • Brilliant. Just testing it out and worked perfectly - thanks for the help! – AnonWonderer Jan 10 '17 at 16:53
1

You could try adding a new column to your DataExtension called "ImageURL" (DataType: TEXT) and populate it with the full "File URL" (Portfolio -> Image -> Properties) and then use AMPScript to lookup that value:

<img src="%%=v(@ImageURL)=%%" Height="100" Width="100"/>

Alternatively, you could concatenate your Portfolio Base URL with the ExternalKey ; assuming the image type (JPG/PNG) is always the same:

<img src="%%=v(Concat(@YourPortfolioBaseURL,@YourImageKey,'.jpg'))=%%" height="100" width="100">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.