Hide Image Placeholder and No Image based on img_url contains

Seeking assistance with code to hide the “No Image” placeholder image and recover that page space based on something like:

{%- if img_url contains “no-image” -%} style=“display: none;” {%- endif -%}

Shopify’s “no image” default URL is:

https://cdn.shopify.com/shopifycloud/shopify/assets/no-image-…

Theme is Radiance

(Update) OR:

{%- unless product.img_url contains “no-image” -%} do this:

{% if settings.main_image_display == ‘Lightbox’ %}

{% endif %}

{{ product.title | escape }}

{% if settings.main_image_display == ‘Lightbox’ %}

{% endif %}

{{ product.title }} | GENUINE {{product.vendor}}

CLICK IMAGE TO ZOOM IN

    {% for image in product.images %} {% unless forloop.first and settings.main_image_display == 'Lightbox' %}
  • <a{% if settings.main_image_display == ‘Lightbox’ %} rel=“fancybox”{% endif %} class=“gallery” href=“{{ image | product_img_url: ‘original’ }}” title=“{{ image.alt | escape }}”>
    {{ image.alt | escape }}

  • {% endunless %}
    {% endfor %}

    {% endunless %}

    Thank you!

Hi @SeekingLiquid ,

no-image means images that do not exist. So you need if image instead of url. Ex:

{% if image %} or {% if image != blank %}

Hope it clear to you.

1 Like

Thank you! It seems that {% if image != blank %} removes all images of any kind (blank and not blank) from:

{% if image != blank %}

{% if settings.main_image_display == ‘Lightbox’ %}

{% endif %}

{{ product.title | escape }}

{% if settings.main_image_display == ‘Lightbox’ %}

{% endif %}

{{ product.title }} | GENUINE {{product.vendor}}

CLICK IMAGE TO ZOOM IN

    {% for image in product.images %} {% unless forloop.first and settings.main_image_display == 'Lightbox' %}
  • {% if product.images.size > 0 %} ur text

    <a{% if settings.main_image_display == ‘Lightbox’ %} rel=“fancybox”{% endif %} class=“gallery” href=“{{ image | product_img_url: ‘original’ }}” title=“{{ image.alt | escape }}”>
    {{ image.alt | escape }}
    {% endif %}

  • {% endunless %}
    {% endfor %}
    {% endif %}

Hi @SeekingLiquid ,

It’s not an if that covers the entire code, it’s just an if at the image location. Ex:

{% if product.featured_image %}

{% endif %}

Therefore, no-images will not be displayed.

Hope it clear to you.