Feature_image link relative and absolute


#1

Hi, I would like to understand why in some posts, the image of the post has an absolute link

<figure class = "post-full-image" style = "background-image: url (https://*****.com/content/images/2018/10/nginx-1.png)">
</figure>

In other posts, the image has a relative link

<figure class = "post-full-image" style = "background-image: url (/content/images/2018/10/nginx-1.png)">
</figure>

What is this difference due to?
This creates problems when I use the feature_image variable with Algolia


#2

@giacomosilli In Ghost themes, you can set whether the {{img_url}} handlebars helper outputs relative or absolute urls. By default feature image URLs are relative, IIRC, but that can be overridden like so: {{img_url feature_image absolute="true"}}. What theme are you using?


#3

I use a very modified version of https://blog.ghost.org
This is the code I have in my posts.hbs file

    {{#if feature_image}}
    <figure class="post-full-image" style="background-image: url({{feature_image}})">
        <div class="post-full-introauthors">
            {{> components/author-accordion}}
        </div>
    </figure>
    {{/if}}

The strange thing is that in some posts, there is a relative link and in others it is absolute.


#4

@giacomosilli I’m not sure this is related, but IIRC {{feature_image}} has been depreciated in favour of {{img_url feature_image}}. You could run your theme through gscan.ghost.org to confirm.


#5

I’m sorry for the delay in the reply.

I did not know about this change.

However I solved by uploading the photos again to update the link for those I needed


closed #6

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.