Hello I'm trying to edit an image make it smaller or custom size but not familiar with liquid. Thank you for the help guys. I added some code. I think its default as certain percentage but not sure. Let me know if you guys need some extra code or information from me.
// settings_data.json file
"index-newsletter": {
"type": "index-newsletter",
"settings": {
"title": "Newsletter",
"richtext": "<p>Subscribe to get special offers, free giveaways, and once-in-a-lifetime deals.<\/p>",
"width": "full",
"flex_align": "align--middle-left",
"text_color": "dark",
"height": "screen-height-one-third",
"bg_image": "shopify:\/\/shop_images\/Grazioso_Logo321321_db2a67b3-d13f-4d64-a73d-c82f176fd6a5.png",
"overlay_opacity": 50,
"overlay_color": "#ffffff"
}
},
<!-- /sections/newsletter.liquid -->
{%- assign img_url = section.settings.bg_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
<style>
{%- if section.settings.text_color == 'white' -%}
.index-newsletter-{{ section.id }},
.index-newsletter-{{ section.id }} .input-group.newsletter-form input { color: #fff; }
{%- endif -%}
</style>
<div class="index-newsletter index-newsletter-{{ section.id }}" data-section-id="{{ section.id }}" data-section-type="newsletter">
<div class="wide-image js-overflow-container {{ section.settings.height }}"
data-aos-duration="500"
data-aos="fade-up">
<div class="hero__content__wrapper hero__content--transparent {{ section.settings.flex_align }}">
<div class="hero__content hero__content--{{ section.settings.width }} js-overflow-content">
<div class="newsletter__content">
{% if section.settings.title != '' %}
<h5 class="newsletter__title">{{ section.settings.title }}</h5>
{% endif %}
{% if collection.description != '' %}
<div class="rte">
{{ section.settings.richtext }}
</div>
{% endif %}
<div class="newsletter-signup">
{% include 'newsletter-form' %}
</div>
</div>
</div>
</div>
{% if section.settings.bg_image %}
{% if section.settings.height == 'image-height' %}
<img class="lazyload responsive-wide-image"
alt="{{ section.settings.bg_image.alt | default: section.settings.title }}"
src="{{ section.settings.bg_image | img_url: '18x' }}"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
data-aspectratio="{{ section.settings.bg_image.aspect_ratio }}"
data-parent-fit="cover"
data-sizes="auto"/>
{% else %}
<div class="background-size-cover lazyload" data-bgset="{% include 'bgset', image: section.settings.bg_image %}"></div>
{% endif %}
<noscript>
<img src="{{ section.settings.bg_image | img_url: '1440x' }}" alt="{{ section.settings.bg_image.alt | default: collection.title }}" class="responsive-wide-image"/>
</noscript>
{% assign overlay_opacity = section.settings.overlay_opacity | times: 0.01 %}
<div class="image-overlay" style="background-color:{{ section.settings.overlay_color }} !important; opacity:{{ overlay_opacity }};"></div>
{% endif %}
</div>
</div>
{% schema %}
{
"name": "Newsletter",
"settings": [
{
"type": "header",
"content": "Content"
},
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Newsletter"
},
{
"id": "richtext",
"type": "richtext",
"label": "Subheading",
"default": "<p>Subscribe to get special offers, free giveaways, and once-in-a-lifetime deals.</p>"
},
{
"type": "paragraph",
"content": "Subscribers are under 'Accepts Marketing' in your [customer admin](/admin/customers)."
},
{
"type": "select",
"id": "width",
"label": "Width",
"default": "full",
"options": [
{ "value": "full", "label": "Full" },
{ "value": "default", "label": "Default" }
]
},
{
"type": "select",
"id": "flex_align",
"label": "Text alignment",
"default": "align--middle-left",
"options": [
{ "value": "align--middle-left", "label": "Left" },
{ "value": "align--middle-center", "label": "Center" },
{ "value": "align--middle-right", "label": "Right" }
]
},
{
"type": "select",
"id": "text_color",
"label": "Text color",
"default": "dark",
"options": [
{ "value": "dark", "label": "Dark" },
{ "value": "white", "label": "White" }
]
},
{
"type": "select",
"id": "height",
"label": "Section height",
"default": "screen-height-one-third",
"options": [
{ "value": "screen-height-one-half", "label": "1/2 of screen"},
{ "value": "screen-height-one-third", "label": "1/3 of screen"},
{ "value": "five-fifty-height-hero ", "label": "550px" },
{ "value": "four-fifty-height-hero", "label": "450px" },
{ "value": "three-fifty-height-hero", "label": "350px" },
{ "value": "two-fifty-height-hero", "label": "250px" },
{ "value": "image-height", "label": "Image height" }
]
},
{
"type": "header",
"content": "Background"
},
{
"type": "image_picker",
"id": "bg_image",
"label": "Background image"
},
{
"type": "range",
"id": "overlay_opacity",
"label": "Opacity",
"info": "Increase contrast for legible text.",
"unit": "%",
"min": 0,
"max": 90,
"step": 5,
"default": 0
},
{
"type": "color",
"id": "overlay_color",
"label": "Overlay color",
"default": "#fff"
}
],
"presets": [
{
"category": "Promotional",
"name": "Newsletter"
}
]
}
{% endschema %}
{% if section.settings.bg_image %}
{% if section.settings.height == 'image-height' %}
<img class="lazyload responsive-wide-image"
alt="{{ section.settings.bg_image.alt | default: section.settings.title }}"
src="{{ section.settings.bg_image | img_url: '18x' }}"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
data-aspectratio="{{ section.settings.bg_image.aspect_ratio }}"
data-parent-fit="cover"
data-sizes="auto"/>
{% else %}
<div class="background-size-cover lazyload" data-bgset="{% include 'bgset', image: section.settings.bg_image %}"></div>
{% endif %}
{
"type": "select",
"id": "height",
"label": "Section height",
"default": "screen-height-one-third",
"options": [
{ "value": "screen-height-one-half", "label": "1/2 of screen"},
{ "value": "screen-height-one-third", "label": "1/3 of screen"},
{ "value": "five-fifty-height-hero ", "label": "550px" },
{ "value": "four-fifty-height-hero", "label": "450px" },
{ "value": "three-fifty-height-hero", "label": "350px" },
{ "value": "two-fifty-height-hero", "label": "250px" },
{ "value": "image-height", "label": "Image height" }
]
},
in the theme editing, if you choose the height setting to image height. These will happen
because you are using lazyload, there will be a small picture of 18px used, hence this line src="{{ section.settings.bg_image | img_url: '18x' }}"
the picture will automatically resize base on the screen width;
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
if you want to have the image at max-width 2048, just remove the the number from data-width; I.e. I only want image size 180 - 2048. I will remove 2450, 2700, 3000, ...
another solution is to add max-width to the image;i.e add style="max-width: 500px" to the img tag
{% if section.settings.bg_image %}
{% if section.settings.height == 'image-height' %}
<img class="lazyload responsive-wide-image"
alt="{{ section.settings.bg_image.alt | default: section.settings.title }}"
src="{{ section.settings.bg_image | img_url: '18x' }}"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
data-aspectratio="{{ section.settings.bg_image.aspect_ratio }}"
data-parent-fit="cover"
data-sizes="auto"/
style="max-width: 500px;">
{% else %}
<div class="background-size-cover lazyload" data-bgset="{% include 'bgset', image: section.settings.bg_image %}"></div>
{% endif %}
Related
I have multiple blogs on my Shopify site. I'm trying to display posts from ALL blogs on the site in the featured section on the homepage. However, when I attempt to select them in the admin area, it only allows me to select one at a time.
What do I need to put in the {% schema %} (or template code) to allow me to select more than one blog in the theme's admin area, thus displaying posts from more than one blog in featured section in the template?
Here is my current {% schema %}:
{% schema %}
{
"name": "Blog posts",
"class": "index-section",
"settings": [
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Blog posts"
},
{
"id": "blog",
"type": "blog",
"label": "Blog"
},
{
"type": "range",
"id": "post_limit",
"label": "Posts",
"min": 3,
"max": 12,
"step": 3,
"default": 3
},
{
"type": "checkbox",
"id": "blog_show_author",
"label": "Show author",
"default": false
},
{
"type": "checkbox",
"id": "blog_show_date",
"label": "Show date",
"default": true
},
{
"type": "checkbox",
"id": "show_view_all",
"label": "Show 'View all' button",
"default": false
}
],
"presets": [
{
"name": "Blog posts",
"category": "Blog",
"settings": {
"blog": "News",
"post_limit": 3
}
}
]
}
{% endschema %}
Have you tried the simplest of Liquid constructions like:
{% for blog in blogs %}
<p>I am blog {{ blog.title }}</p>
{% endfor %}
That kind of thing? If you have many blogs, I would start with that. If you cannot iterate your existing blogs, you have no hope of showing off their contents in a section of your store, whatever that may be.
Could you try this? Just add some more block schema
<div class = "blog-container">
{% if section.settings.blog != blank %}
{% for blog in section.settings.blog %}
<p>{{blog.title}}</p>
{% endfor %}
{% endif %}
{% if section.settings.blogone != blank %}
{% for blog in section.settings.blogone %}
<p>{{blog.title}}</p>
{% endfor %}
{% endif %}
{% if section.settings.blogtwo != blank %}
{% for blog in section.settings.blogtwo %}
<p>{{blog.title}}</p>
{% endfor %}
{% endif % }
</div>
{% schema %}
{
"name": "Blog posts",
"class": "index-section",
"settings": [
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Blog posts"
},
{
"id": "blog",
"type": "blog",
"label": "Blog"
},
{
"id": "blogtwo",
"type": "blog",
"label": "Blog Two"
},
{
"id": "blogthree",
"type": "blog",
"label": "Blog Three"
},
{
"type": "range",
"id": "post_limit",
"label": "Posts",
"min": 3,
"max": 12,
"step": 3,
"default": 3
},
{
"type": "checkbox",
"id": "blog_show_author",
"label": "Show author",
"default": false
},
{
"type": "checkbox",
"id": "blog_show_date",
"label": "Show date",
"default": true
},
{
"type": "checkbox",
"id": "show_view_all",
"label": "Show 'View all' button",
"default": false
}
],
"presets": [
{
"name": "Blog posts",
"category": "Blog",
"settings": {
"blog": "News",
"post_limit": 3
}
}
]
}
{% endschema %}
This is the current code:
<img src="{{ block.settings.imageId| img_url: 'large'}}" />
{% schema %}
{
"name": "Single Mobile Image",
"class": "mobile-index-section",
"max_blocks": 1,
"blocks": [
{
"type": "image_picker",
"name": "Mobile Image",
"settings": [
{
"type": "image_picker",
"id": "imageId",
"label": "Mobile Image"
}
]
}
],
"presets": [
{
"name": "Custom Mobile Image",
"category": "Image",
"blocks": [
{
"type": "image_picker"
}
]
}
]
}
{% endschema %}
When using {{ block.settings.imageId| img_url: 'large'}} , I'm not getting the image which is added on shopify customization using image picker.
Please help me to find out where I did mistake.
sections.blocks is an array element, you need to loop it or target a specific index.
In your case {{ section.blocks[0].settings.imageId | img_url: '1024x'}} will get you the first block.
In addition don't use named sizes, they are deprecated: https://shopify.dev/docs/themes/liquid/reference/filters/deprecated-filters#named-size-parameters.
I achieved success to add new block in Shopify using schema and Shopify liquid. I have added schema which is expected to adjust the width of an image one on left side and one for right side.I am quite close but something missing here.Is there something wrong with style="width:{{img_width}}vw" or Image width schema ? Thanks
Both image width slider does not make difference with image screenshot.
{% elsif block.type == 'side_by_side' %}
<div class="container">
<div class="eight columns image_column">
{% if block.settings.image-left %}
<p>
{% assign image_left_width = block.settings.image_width %}
<img src="{{ block.settings.image-left | img_url: '300x', scale: 2}}" style="width:{{image_left_width}}vw" alt="{{block.settings.image-left.alt}}" class="lazyload transition-in"/>
</p>
{% endif %}
</div>
<div class="eight columns image_column">
{% if block.settings.image-right %}
<p>
{% assign image_rigth_width = block.settings.image_width %}
<img src =" {{ block.settings.image-right | img_url: '300x', scale: 2}}" style="width:{{image_right_width}}vw" alt="{{block.settings.image-right.alt}}" class="lazyload transition-in" >
</p>
{% endif %}
</div>
</div>
Image block Schema
{
"type": "side_by_side",
"name": "side_by_side",
"settings": [
{
"type": "image_picker",
"id": "image-left",
"label": "Image-left"
},
{
"type": "range",
"id": "image_left_width",
"label": "Image width",
"min": 50,
"max": 100,
"step": 5,
"default": 100,
"unit": "vw"
},
{
"type": "image_picker",
"id": "image-right",
"label": "Image-right"
},
{
"type": "range",
"id": "image_right_width",
"label": "Image width",
"min": 50,
"max": 100,
"step": 5,
"default": 100,
"unit": "vw"
},
{
"type": "select",
"id": "layout",
"label": "Layout",
"default": "left",
"options": [
{
"value": "left",
"label": "Image on left"
},
{
"value": "right",
"label": "Image on right"
}
]
},
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Side by Side Engineering "
},
{
"type": "richtext",
"id": "text",
"label": "Text",
"default": "<p>Pair text with an image to give focus to your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.</p>"
},
{
"type": "select",
"id": "text_alignment",
"label": "Text alignment",
"options": [
{
"value": "left",
"label": "Left"
},
{
"value": "center",
"label": "Center"
},
{
"value": "right",
"label": "Right"
}
],
"default": "left"
},
{
"type": "text",
"id": "button_label",
"label": "Button label"
},
{
"type": "url",
"id": "button_link",
"label": "Button link"
}
]
},
Thats because you are assigning a null value and using that null value.
{% assign image_left_width = block.settings.**image_width** %}
Note that, in your schema there is no element with id = image_width. You already have elements with id = image_left_width / image_right_width. But now, you are creating a new variable image_left_width and assigning it with a null value. Then you are setting your image width that null value. Why not just skip the "assign" code? i.e. delete that line. like..
<p>
<img src="{{ block.settings.image-left | img_url: '300x', scale: 2}}" style="width:{{block.settings.image_left_width}}vw" alt="{{block.settings.image-left.alt}}" class="lazyload transition-in"/>
</p>
If you still want to first assign into a new variable then do this.
{% assign image_left_width = block.settings.image_left_width %}
I'm trying to add the product url and image to a div within a slider. However, I added the product dropdown to the schema, but it isn't pulling the data to the div. Please find the schema below:
{% schema %}
{
"name": "Product-Slideshow",
"settings": [
{
"id": "text-box",
"type": "text",
"label": "Heading",
"default": "Title"
}
],
"blocks": [
{
"type": "select",
"name": "Add Product",
"settings": [
{
"type": "product",
"id": "id",
"url": "url",
"label": "text",
"info": "text"
},
]
}
],
"presets": [
{
"name": "Product-Slideshow",
"category": "Image",
"blocks": [
{
"type": "select"
},
{
"type": "select"
}
]
}
]
}
{% endschema %}
Here is the div it is to be placed in.
<div class="owl-carousel">
{% for block in section.blocks %}
<div><a href="{{ product.url }}" class="btn"><img src="{{ image.src |
product_img_url }}"></a></div>
{% endfor %}
</div>
Any help would be greatly appreciated.
You must call your block settings as explained here :
https://help.shopify.com/themes/liquid/objects/block#block-settings
For example, something like {{ block.settings.image }}
I have 8 feature products added in my settings_schema.json . I want to output them by for loop by adding number on the end of settings.feature_product[incrementing integer]
This is my settings schema
{
"type": "product",
"id": "feature_product1",
"label": "Feature Product 1"
},
{
"type": "product",
"id": "feature_product2",
"label": "Feature Product 2"
},
{
"type": "product",
"id": "feature_product3",
"label": "Feature Product 3"
},
{
"type": "product",
"id": "feature_product4",
"label": "Feature Product 4"
},
{
"type": "product",
"id": "feature_product5",
"label": "Feature Product 5"
},
{
"type": "product",
"id": "feature_product6",
"label": "Feature Product 6"
},
{
"type": "product",
"id": "feature_product7",
"label": "Feature Product 7"
},
{
"type": "product",
"id": "feature_product8",
"label": "Feature Product 8"
}
This is the code in my snippet
{% for i in (1..8) %}
{% if i <= 8 %}
<div class="case_item">
{% assign case_var = 'settings.feature_product' | append: i | strip_html %}
{{ all_products[case_var].title }}
</div>
{% endif %}
{% endfor %}
But it doesn't work :( I tried to print the case_var and the result is..
settings.feature_product1
settings.feature_product2
.
.
settings.feature_product3
Anyone could help me?
{% for i in (1..8) %}
{% capture productid %}feature_product{{ i }}{% endcapture %}
{% if settings[productid] != '' %}
<div class="case_item">
{% assign productslug = settings[productid] %}
<h3>{{ all_products[productslug].title }}</h3>
<em>{{ all_products[productslug].price | money }}</em>
</div>
{% endif %}
{% endfor %}