AMP code for publication image?


#1

First, disclaimer, I’m bad at this.

So, I grabbed the default amp.hbs file and started playing around to get used to it. I’m trying to add the blog’s image to the header using the AMP image code. I don’t want to just link to an image uploaded, so it would reflect future changes.

Could someone give me an AMP HTML code line that I could use in the header using the handlebars {{@blog.logo}} code?


#2

Hey @em_div

did you see this:

You should be able to use it like this:

{{#if @blog.logo}}
    <amp-img src={{@blog.logo}} width="600" height="400" layout="responsive"></amp-img>
{{/if}}

#3

I did see that. I didn’t format it properly, it seems. Is it required to use the IF?


#4

It is not required, but a blog logo is not always present, so it’s a good practice using a conditional. Will also make it easier to use different classes in your CSS. But totally up to you.