Personalized checkout and custom promotions with Shopify Scripts
Hello at all,
i try to embed an Image in a Section block but it doesn´t work. Maybe someone can help me.
I am new with Shopify and need some help.
Here is the section block I want to add:
"blocks": [
{
"type": "image",
"name": "Image",
"settings": [
{
"type": "url",
"id": "link",
"label": "Image"
},
]
and here is are my section-properties:
<div {% render 'section-properties' %}>
<media-with-text class="media-with-text {% if section.settings.spacing == 'none' %}{% if section.settings.full_width %}full-bleed{% else %}rounded{% endif %}{% endif %}">
{%- for block in section.blocks -%}
<div id="block-{{ section.id }}-{{ block.id }}" class="media-with-text__item" {{ block.shopify_attributes }}>
<div class="media-with-text__media {% unless section.settings.spacing == 'none' %}rounded{% endunless %}" reveal-on-scroll="true">
{%- if block.type == 'image' -%}
{%- if block.settings.image != blank -%}
{%- assign width_ratio = 100.0 | divided_by: block.settings.media_width -%}
{%- assign maximum_image_width = settings.page_width | divided_by: width_ratio -%}
{%- capture sizes -%}(max-width: 999px) 100vw, min({{ maximum_image_width | ceil }}px, {{ block.settings.media_width }}vw){% endcapture %}
{{- block.settings.image | image_url: width: block.settings.image.width | image_tag: loading: 'lazy', sizes: sizes, widths: '300,400,500,600,700,800,1000,1200,1400,1600,1800,2000,2200,2400,2600' -}}
{%- else -%}
{{- 'image' | placeholder_svg_tag: 'aspect-short placeholder' -}}
{%- endif -%}
{%- else -%}
{%- if block.settings.video -%}
<video-media autoplay>
{{- block.settings.video | video_tag: playslinline: true, muted: true, loop: true, preload: 'metadata' -}}
</video-media>
{%- else -%}
<video-media host="{{ block.settings.external_video_url.type }}" autoplay>
<template>
{%- if block.settings.external_video_url.type == 'youtube' -%}
<iframe src="https://www.youtube.com/embed/{{ block.settings.external_video_url.id }}?playsinline=1&autoplay=1&controls=0&mute=1&loop=1&playlist={{ block.settings.external_video_url.id }}&enablejsapi=1&rel=0&modestbranding=1&origin={{ 'https://' | append: request.host | url_encode }}" allow="autoplay; encrypted-media" allowfullscreen="allowfullscreen"></iframe>
{%- elsif block.settings.external_video_url.type == 'vimeo' -%}
<iframe src="https://player.vimeo.com/video/{{ block.settings.external_video_url.id }}?autoplay=1&autopause=1&background=1&loop=1&muted=1&transparent=0&responsive=1&portrait=0&title=0&byline=0&color={{ settings.text_color | remove_first: '#' }}" allow="autoplay; encrypted-media;" allowfullscreen="allowfullscreen"></iframe>
{%- endif -%}
</template>
</video-media>
{%- endif -%}
{%- endif -%}
</div>
{%- capture content_class -%}media-with-text__content {% unless section.settings.spacing == 'none' %}rounded{% endunless %}{%- endcapture -%}
<div {% render 'surface', class: content_class, background: block.settings.background, background_gradient: block.settings.background_gradient, text_color: block.settings.text_color %}>
<div class="prose break-all {{ block.settings.text_position }}" reveal-on-scroll="true">
{%- if block.settings.custom_icon != blank -%}
{%- capture sizes -%}{{ block.settings.icon_width }}px{%- endcapture -%}
{%- capture widths -%}{{ block.settings.icon_width }}, {{ block.settings.icon_width | times: 2 | at_most: block.settings.custom_icon.width }}{%- endcapture -%}
{{- block.settings.custom_icon | image_url: width: block.settings.custom_icon.width | image_tag: loading: 'lazy', sizes: sizes, widths: widths, class: 'media-with-text__icon' -}}
{%- elsif block.settings.icon != 'none' -%}
{%- render 'icon' with block.settings.icon, width: block.settings.icon_width, height: block.settings.icon_width, class: 'media-with-text__icon' -%}
{%- endif -%}
{%- if block.settings.subheading != blank -%}
<p class="bold">{{ block.settings.subheading | escape }}</p>
{%- endif -%}
{%- if block.settings.title != blank -%}
<p class="h2 media-with-text">
{%- render 'styled-text', content: block.settings.title, gradient: block.settings.text_gradient -%}
</p>
{%- endif -%}
{{- block.settings.content -}}
{%- if block.settings.link_text != blank -%}
{%- render 'button', href: block.settings.link_url, content: block.settings.link_text, size: 'xl', background: block.settings.button_background, text_color: block.settings.button_text_color -%}
{%- endif -%}
</div>
</div>
</div>
{%- endfor -%}
</media-with-text>
</div>
I think one code is missing but i don´t know which one in the section-properties.
Can someone help me?
Thank you
Andy
"blocks": [
{
"type": "image_block",
"name": "image_block",
"settings": [
{
"type": "image_picker",
"id": "image",
"label": "Image "
}
]
Use this paragraph to configure if you just want to add blocks of images.
Hello,
If I try to add this code to my liquid, I get this error:
I want to add images in the section via URL (metafield)
I do not want to add images via selection
Do you have any Idea why this error is showing up?
Thanks Andy
I've tried this code on my side and it doesn't report an error, if it does it may be due to the brackets, if you need me to check it for you you can contact me.Try this
"blocks": [
{
"type": "image_block",
"name": "image_block",
"settings": [
{
"type": "image_picker",
"id": "image",
"label": "Image "
}
]
}
]
hmm.. no it doesn´t work without this message....
would be great if you could assist me.
the section is called:
"media-url-with-text"
I want to embed images via URL and with the current settings I am not able to choose a URL Metafield - just Data Metafields.
My URL is:
https://bavariashop-mei-lebensgfui.myshopify.com/
can you apply for access?
I have applied, please tell me what you need to do now. Configure the metafield? Or do you go ahead and implement adding blocks to configure images?
If you need to, you can contact me by email.
My Email:d1300715301@gmail.com
We want to go ahead to get a possibility to add images via URL in this section.
Thank you, I already sent an email.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024