Adding blog thumbnails to search results (in Minimal Theme)

Shopify Expert
195 0 23

Hi John,

Featured images on a blog post are now a feature in Shopify. You will see a place in the blog admin to put an image and they can be access in the theme with:

{{ article.image }}

Details here: https://docs.shopify.com/themes/liquid-documentation/objects/article#article-image

Cheers,

Ryan

@HWTrenches

Stop Stressing About Shopify You’ve Got Better Things To Do => https://320ny.com/shopify/
1 Like
Highlighted
Shopify Partner
650 0 93

Sweet news

0 Likes
New Member
20 0 0

That's fantastic! Thanks for letting me know Ryan. Appreciate it. 

Best,

John

 

0 Likes
Tourist
15 0 1

Hi guys,

Using Minimal and trying to use the new feature, however after uploading an image as a featured image for my blog post, it still doesn't appear in search results. It does show correctly in the blog admin though (see below). Anything I'm doing wrong? I don't have access to the css/html, on starter plan.

Thanks for any input!

Nic

0 Likes
Shopify Expert
195 0 23

Hi Nic,

This is a new feature so your theme probably does not have this built in. In order to have the featured image display in search results you will need to alter some html in the theme include soemthing like this:

{% if article.image %}
  <img src="{{ article | img_url: 'medium' }}">
{% endif %}

If you want to do this you will have to upgrade past the Starter plan.

-Ryan

Stop Stressing About Shopify You’ve Got Better Things To Do => https://320ny.com/shopify/
0 Likes
Tourist
15 0 1

Thanks for your help Ryan!

0 Likes
Shopify Partner
4 0 0

Hi Ryan, I'm new to this thread, but I have to say thanks so much for your guidance!
I'm unable to render this in search.liquid -- do you have any thoughts as to why it's not returning the featured image?  Thanks in advance.
 

{% if item.object_type == 'article' %}
    {% if article.image %}
      <div class="grid__item one-third">
        <a href="{{ item.url }}" title="{{ item.title | escape }}">
            <img src="{{ article | img_url: 'medium' }}">
        </a>
      </div>
    {% endif %}
{% endif %}

 

0 Likes
Shopify Expert
195 0 23

Update yout code to this:

{% if item.object_type == 'article' %}
    {% if item.image %}
      <div class="grid__item one-third">
        <a href="{{ item.url }}" title="{{ item.title | escape }}">
            <img src="{{ item | img_url: 'medium' }}">
        </a>
      </div>
    {% endif %}
{% endif %}

You have to reference the item variable as that is the actual artice object. The article variable is not defined here. 

Stop Stressing About Shopify You’ve Got Better Things To Do => https://320ny.com/shopify/
0 Likes
Shopify Partner
4 0 0

Oh sweet, silly me.  Thanks so much Ryan!!

0 Likes
Shopify Partner
199 0 21

5 Months later and Ryan is still kicking ass!

0 Likes