How can I create a consistent image gallery grid for the Prestige Theme?

I am working on creating a “Gallery Grid” similar to the Dawn Theme that can be compatible with Prestige Theme. (It seems that one of the biggest complaints with Shopify is that there is not an easy way to show a bunch of images with captions without either paying for a custom coder or using a third party app.)

So far the code works but I have noticed a couple issues:

  1. somewhere I am missing code needed to make the grid alignment/sizing consistent for mobile view (see screenshots, ignore the blue that is hiding info)

  2. Depending on how much text is below the image, it effects the image size (even though the aspect ratio of the images is the same PER ROW)

  3. if you only put one or two images, there will still be padding for the missing image (this can be worked around by using specific image-picker boxes in each block but it is still inconvenient)

Below is the code I have pieced together using examples of other sections, I am still a bit new at CSS so it might be redundant or “the long way” to code:

.


{% schema %}
  {
    "name": "Full Installation Gallery",
   

	"settings": [
					{
						"type":"text",
						"label":"Section Headline",
						"id":"heading",
                    	"default":"Headline"
					},
                    {
      					"type":"text",
     					"label":"Sub Heading",
                        "id":"subheading",
                        "default":"Subheading"
   					},
					{
						"type":"richtext",
						"label":"Section Description",
						"id":"description",
						"default":"

 Description Text... 

"
					}
  				],

	"blocks" : [
					{
						"type":"image",
						"name":"image block",
						"settings": [
										{
											"type":"image_picker",
											"label":"Select Image",
											"id":"image1",
											"info": "1200 x 1200px .jpg recommended"
										},
										{
											"type": "richtext",
         									 "id": "link_text1",
         									 "label": "link text 1",
											"default":"

"
        								},
										{
											"type":"image_picker",
											"label":"Select Image",
											"id":"image2",
											"info": "1200 x 1200px .jpg recommended"
										},
										{
											"type": "richtext",
          									"id": "link_text2",
          									"label": "link text 2",
											"default":"

"
        								},
										{
											"type":"image_picker",
											"label":"Select Image",
											"id":"image3",
											"info": "1200 x 1200px .jpg recommended"
										},
										{
											"type": "richtext",
          									"id": "link_text3",
          									"label": "link text 3",
											"default":"

"
        								}
									]
					}
  				],
	

	"presets" : [
					{
						"category":"image",
						"name":"Full Installation Gallery",
      					"blocks": [
      					  {
         					 "type": "image"
        				}
     							 ]
					}
				]
  }
{% endschema %}

Hi @coria_stephanie ,

Please change code:

Code:

=>

and

=>

Hope it helps!

@LitExtension

So definitely fixed the sizing issue, even on mobile!

Buuuut, for the single image it shifted it to the left instead of keeping it centered:

I think it is better without the otherwise it makes the spacing is more grid-like rather than masonry if an image is missing:

Hi @coria_stephanie ,

Now, do you want when uploading 1 image to display full, 2 images to display 50% and 3 to display as it is?

Or is it all divided by 3, just make it show to the left.

I will check it.

@LitExtension

Best would be 1 image centered (full would be great since I am mainly using widescreen 16:9 images for the single only), 2 images is 1/2 each, and 3 images is 1/3 each.

There aren’t really restrictions at the moment for the height of the rows so that is helping with the masonry grid look so vertical images look taller rather than all images try to fit within a “grid box” so to speak.

Right now I have about 10px padding to create spacing between images and the screen border.

Hi @coria_stephanie ,

Please change code:


{% schema %}
  {
    "name": "Full Installation Gallery",
   

	"settings": [
					{
						"type":"text",
						"label":"Section Headline",
						"id":"heading",
                    	"default":"Headline"
					},
                    {
      					"type":"text",
     					"label":"Sub Heading",
                        "id":"subheading",
                        "default":"Subheading"
   					},
					{
						"type":"richtext",
						"label":"Section Description",
						"id":"description",
						"default":"

 Description Text... 

"
					}
  				],

	"blocks" : [
					{
						"type":"image",
						"name":"image block",
						"settings": [
										{
											"type":"image_picker",
											"label":"Select Image",
											"id":"image1",
											"info": "1200 x 1200px .jpg recommended"
										},
										{
											"type": "richtext",
         									 "id": "link_text1",
         									 "label": "link text 1",
											"default":"

"
        								},
										{
											"type":"image_picker",
											"label":"Select Image",
											"id":"image2",
											"info": "1200 x 1200px .jpg recommended"
										},
										{
											"type": "richtext",
          									"id": "link_text2",
          									"label": "link text 2",
											"default":"

"
        								},
										{
											"type":"image_picker",
											"label":"Select Image",
											"id":"image3",
											"info": "1200 x 1200px .jpg recommended"
										},
										{
											"type": "richtext",
          									"id": "link_text3",
          									"label": "link text 3",
											"default":"

"
        								}
									]
					}
  				],
	

	"presets" : [
					{
						"category":"image",
						"name":"Full Installation Gallery",
      					"blocks": [
      					  {
         					 "type": "image"
        				}
     							 ]
					}
				]
  }
{% endschema %}

I helped you add conditions to it.

Hope it helps!

@LitExtension

This is perfect!!

Do you have any recommendations for articles about condition writing? This is where I still need to do some more self-teaching.

Hi @coria_stephanie ,

Refer

Hope it is clear to you.