Adding Product Featured Images (Not Collection Images) to Sub Navigation

New Member
1 0 0

Hi!

 

I have been busting my brain cells on something that looks like its an easy line of code :(   I currently have a nice navigation that has a mix of linking directly to a product and a collection and when on drop down, the collection images are displayed but I would like to know how to also have the featured product image display as well?  Currently I have a bunch of "NO IMAGE" place holder images in the spots where I have linked directly to the product (because I'm assuming my code is thinking it is a collection?) I tried switching the img src code from child_link_collection.image.src to product.featured_image but no go...  At any rate - here is my main.nav.liquid code below and a current screenshot of the drop down menu.  Hopefully someone has some advice, thoughts, feedback on this - I don't think I need to buy an app...

 

 {% assign child_list_handle = link.title | handle %}
      {% if linklists[child_list_handle] and linklists[child_list_handle].links.size > 0 %}
      <li class="has-dropdown first_li">
        {{ link.title | link_to: link.url }}
        <ul class="second_ul">
          {% for child_link in linklists[child_list_handle].links %}
          {% assign grand_child_list_handle = child_link.title | handle %}
          {% if linklists[grand_child_list_handle] and linklists[grand_child_list_handle].links.size > 0 %}
          <li class="has-dropdown second_li">
            <div class="link_title">{{ child_link.title | link_to: child_link.url }}</div>
            <ul class="third_ul">
              {% for grand_child_link in linklists[grand_child_list_handle].links %}
              <li class="third_li">
                {{ grand_child_link.title | link_to: grand_child_link.url }}
              </li>
              {% endfor %}
            </ul>
          </li>
          {% else %}
          <li class="second_li no_sub_child">
            {% assign child_link_collection = child_link.object %}
            <a href="{{child_link_collection.url}}">
              <div class="link_title">{{ child_link_collection.title }}</div>
              <div class="collection_img">
                {% if child_link_collection.image %}
                <img src="{{ child_link_collection.image.src | collection_img_url: 'medium' }}" alt="{{ child_link_collection.image.alt }}" />
                {% else %}
                <img src="{{ 'no-image.jpg' | asset_url }}">
                {% endif %}
              </div>
            </a>
          </li>

Screen Shot 2019-06-20 at 10.39.56 PM.png

 

 

0 Likes