Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Add image to my internal site page search results - Dawn Template

Add image to my internal site page search results - Dawn Template

remarkspuzzles
Tourist
13 0 1

If I search for Bookmarks within our internal site search, it pulls up the bookmarks page. Is there a way to make that grey box be an image? We are using the Dawn template. Our URL is remarks.net.

 

ImageHere.jpg

Replies 2 (2)

remarkspuzzles
Tourist
13 0 1

Anyone able to help with this issue? I see two other people with this same question unanswered. Maybe it's not possible?

BlackUmbrella
Shopify Partner
7 0 2

To implement this solution, you'll need to:

  1. First, create a custom metafield for pages:
    • Go to Settings > Custom data > Metafields
    • Select "Pages" as the resource
    • Add a new metafield with:
      • Name:  Featured Image
      • Namespace and Key: (it will automatically generate to 'custom.feature_image')
      • Description: Featured Image
      • Type: file
  2. Add images to your pages:
    • Edit each page
    • Scroll down to the Metafields section
    • Upload the desired featured image

The steps above will add the the option to add a feature image to pages.

  1. Now, Modify your theme code:
    • Go to Online Store > Themes
    • Click "Actions" > "Edit code"
    • Find the main search page (usually in sections/main-search.liquid and comment the below code.

 

 

 

{% comment %}
                      {%- when 'page' -%}
                        <div class="article-card-wrapper card-wrapper underline-links-hover">
                          <div
                            class="card card--card card--text ratio color-{{ settings.blog_card_color_scheme }}"
                            style="--ratio-percent: 100%;"
                          >
                            <div class="card__content">
                              <div class="card__information">
                                <h3 class="card__heading">
                                  <a href="{{ item.url }}" class="full-unstyled-link">
                                    {{ item.title | truncate: 50 | escape }}
                                  </a>
                                </h3>
                              </div>
                              <div class="card__badge {{ settings.badge_position }}">
                                <span class="badge color-{{ settings.color_schemes | first }}">
                                  {{- 'templates.search.page' | t -}}
                                </span>
                              </div>
                            </div>
                          </div>
                        </div>
                      {% endcomment %}​

 

  • Insert the code below, where the code above was, and save.

 

 {%- when 'page' -%}
<div class="article-card-wrapper card-wrapper underline-links-hover">
  <div class="card article-card card--standard{% if item.metafields.custom.featured_image %} card--media{% endif %}" style="--ratio-percent: 100%;">
    <div class="card__inner color-{{ settings.blog_card_color_scheme }} gradient ratio" style="--ratio-percent: 100%;">
      {% if item.metafields.custom.featured_image %}
        <div class="article-card__image-wrapper card__media">
          <div class="article-card__image media media--hover-effect">
            {%- assign image = item.metafields.custom.featured_image -%}
            <img
              srcset="{%- if image.width >= 165 -%}{{ image | image_url: width: 165 }} 165w,{%- endif -%}
                {%- if image.width >= 360 -%}{{ image | image_url: width: 360 }} 360w,{%- endif -%}
                {%- if image.width >= 533 -%}{{ image | image_url: width: 533 }} 533w,{%- endif -%}
                {%- if image.width >= 720 -%}{{ image | image_url: width: 720 }} 720w,{%- endif -%}
                {%- if image.width >= 1000 -%}{{ image | image_url: width: 1000 }} 1000w,{%- endif -%}
                {%- if image.width >= 1500 -%}{{ image | image_url: width: 1500 }} 1500w,{%- endif -%}
                {{ image | image_url }} {{ image.width }}w"
              src="{{ image | image_url: width: 533 }}"
              sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
              alt="{{ image.alt | escape }}"
              class="motion-reduce"
              loading="lazy"
              width="{{ image.width }}"
              height="{{ image.height }}"
            >
          </div>
        </div>
      {% endif %}
      <div class="card__content">
        <div class="card__information">
          <h3 class="card__heading">
            <a href="{{ item.url }}" class="full-unstyled-link">
              {{ item.title | truncate: 50 | escape }}
            </a>
          </h3>
        </div>
        <div class="card__badge top right">
          <span class="badge color-{{ settings.color_schemes | first }}">
            {{- 'templates.search.page' | t -}}
          </span>
        </div>
      </div>
    </div>
    {% if item.metafields.custom.featured_image %}
      <div class="card__content">
        <div class="card__information">
          <h3 class="card__heading">
            <a href="{{ item.url }}" class="full-unstyled-link">
              {{ item.title | truncate: 50 | escape }}
            </a>
          </h3>
        </div>
        <div class="card__badge top right">
          <span class="badge color-{{ settings.color_schemes | first }}">
            {{- 'templates.search.page' | t -}}
          </span>
        </div>
      </div>
    {% endif %}
  </div>
</div>

 

Let me know if that works for you.

Contact for solutions.