Frequently Asked Questions

Product Information

What is the formatted gallery section in Hygraph?

The formatted gallery section is a reusable component in Hygraph that allows you to create image galleries with customizable format options. You can add as many images as you need, select the number of columns for display, and use dropdowns to choose image size and aspect ratio. This component is designed for flexibility and can be reused across different models in your Hygraph project. Learn more.

What are the prerequisites for creating a formatted gallery section in Hygraph?

To create a formatted gallery section, you need a Hygraph account and an active project. You can either create a new project, clone the provided Image Galleries Cookbook project, or use an existing project. Make sure to consider your plan limits when adding new recipes. Sign up here if you don't have an account.

How do I create a formatted image gallery component in Hygraph?

To create a formatted image gallery component, follow these steps:

  1. Create enumerations for aspect ratio and image size, specifying options like 'Original', 'Four by three', 'Sixteen by nine', 'Square', and sizes such as 'Full size', 'Large', 'Medium', and 'Small'.
  2. Add a new component called 'Formatted gallery section' with fields for the gallery title, images (using an asset picker that allows multiple uploads), aspect ratio, image size, and the number of columns (with a range between 2 and 4).
This setup allows you to build flexible and reusable image galleries in your content models. See the full guide.

What fields and options are included in the formatted gallery section component?

The formatted gallery section component includes the following fields:

These fields provide flexibility for customizing the gallery's appearance and structure. See details.

Can I clone a ready-made project with the formatted gallery section?

Yes, Hygraph provides a ready-made project called the Image Galleries Cookbook, which contains all the recipes for creating image galleries, including the formatted gallery section. You can clone this project to explore different gallery configurations without starting from scratch. Clone the project here.

How do I add multiple images to my gallery in Hygraph?

To add multiple images, use the Asset picker field in your formatted gallery section component. When configuring the field, select the 'Allow multiple assets' checkbox. This enables you to upload and manage several images within a single gallery entry. See the quickstart guide.

What are enumerations in Hygraph and how are they used in the gallery component?

Enumerations in Hygraph are predefined sets of values that can be used as dropdown options in your schema. In the formatted gallery section, enumerations are used for selecting the image aspect ratio and image size, allowing editors to standardize formatting across galleries. Learn more about enumerations.

How can I set the number of columns in my image gallery?

The formatted gallery section includes a number field called 'Columns', where you can specify the number of columns (between 2 and 4) for your gallery layout. The field can be set with a default value and input validation to ensure the value stays within the allowed range.

Can I reuse the formatted gallery section component in other models?

Yes, by creating the gallery as a component, you can reuse its structure in different models throughout your Hygraph project. This makes it easy to maintain consistency and efficiency when managing multiple galleries.

Features & Capabilities

What are the benefits of using the formatted gallery section in Hygraph?

The formatted gallery section offers several benefits:

These features help streamline content creation and ensure a consistent visual presentation. Read more.

What other image gallery configurations are available in Hygraph?

Hygraph offers multiple image gallery recipes beyond the formatted gallery section, such as galleries with additional information and styled galleries. You can explore these configurations in the Image Gallery Section Index to find the best fit for your project needs.

Support & Implementation

Where can I find more resources or get help with image galleries in Hygraph?

You can find more resources in the Hygraph documentation, including guides on enumerations, components, and image gallery recipes. For additional help, join the Hygraph Community Slack to ask questions or suggest new recipe ideas. Useful links include the Enumerations Guide and Components Documentation.

Help teams manage content creation and approval in a clear and structured way
Hygraph
Docs

#Formatted gallery section

#Overview

This guide shows how to build an image gallery component with format dropdowns and columns.

This image gallery uses assets in your Hygraph project and allows you to add as many images as you need. It also lets you select the number of columns the gallery will use to display the images, and has dropdowns for image size and aspect ratio.

Formatted gallery section component with fieldsFormatted gallery section component with fields

#Prerequisites

  • REQUIRED: You need to have a Hygraph account. If you don't have one, you can sign up here.
  • REQUIRED: You need to have a Hygraph project.
    • OPTION 1: Create a project. This is the way to go if you want to follow the entire tutorial for learning purposes.
    • OPTION 2: Clone the entire cookbook. This is the way to go if you're curious about how the galleries are made but don't want to follow the step-by-step creation process. This project contains the entire Image galleries Cookbook so you can compare them, or look into what instances they contain.
    • OPTION 3: Use an existing project of yours. If you have a project already and want to add this image gallery to it, this is the way to go. In this case, you may need to adjust parts of the tutorial to your own project schema.

#Core concepts

In this guide, you'll work with a number of schema elements. Let's look into them:

  • Enumerations: an enumeration is a predefined set of values that represents a list of possible options. You can use them to group values within a type.

  • Component: a predefined set of fields that can be reused across models and content entries. You can think of a component as a flexible, reusable template: you define the fields that will be used inside a component once, and then fill them with different content every time you use it in a content entry.

  • Basic component field: a component is a special field type in your Hygraph schema that defines which components of which type can be used in a model. Component fields can be of basic or modular types. A basic component field can only have one component attached to it. You can limit the number of component instances to one, or allow multiple component instances to be added in the content entry.

#What you can do

This guide offers two paths:

  • Path 1: Use this guide to create a formatted image gallery component that you can use in your project.
  • Path 2: Clone the project that we created for you. It contains the entire Image galleries cookbook to compare the different gallery configurations without having to clone multiple projects.

#Clone project

We have prepared a project that contains the entire Image galleries cookbook:

Clone this project

This cookbook contains all the recipes we have so far to create image galleries, so you can compare the different gallery configurations without having to clone multiple projects.

To find this particular recipe in the cookbook project, navigate to the schema and look for the "Formatted galery secton" component.

#Step-by-step guide

In this guide, we will create an image gallery component with columns and format dropdowns.

We will divide this process in steps to make it more manageable:

  1. Create the enumerations: We will create 2 enumerations that will later help us format our galleries; one for image size and another for aspect ratio.
  2. Create the gallery component: We will create an image gallery component that you can later add as component field to your models.

#1. Create the enumerations

We want our image gallery to have dropdowns that will let us select the image aspect ratio and size.

We'll start by creating the enumeration for aspect ratio. We'll click + Add next to Enumerations and use the following information:

FieldInput
Display NameAspect ratio
API IDAspectRatio

Next, we need to add enumeration values. These are the options we will get when using this later on as a dropdown menu.

For every enumeration value, you need to enter a Display name, an API ID, and click Add.

We'll add the following values:

Display nameAPI ID
Originaloriginal
Four by threefourByThree
Sixteen by ninesixteenByNine
Three by twothreeByTwo
Squaresquare

We'll click Add enumeration to save.

Next, we need to create an enumeration for image size selection. We'll repeat the process using the following information:

FieldInput
Display NameImage size
API IDImageSize

Once more, we need to add enumeration values. For this example, we'll use four size options - full size, large, medium and small.

We'll add the following:

Display nameAPI ID
Full sizefullSize
Largelarge
Mediummedium
Smallsmall

We'll click Add enumeration to save.

In the next step, we will create our image gallery component and include them as enumeration fields.

Now that we have the two enumerations that will be a part of our final gallery component, we'll go ahead and create it.

We'll click + Add next to Components and add it using this information:

FieldInput
Display NameFormatted gallery section
API IDFormattedGallerySection
API ID PluralFormattedGallerySections

We'll click Add component to save, and then we'll start adding instances to it.

We'll start with a Single line text field, which will be our gallery section title. Let's add it by clicking Add on the Single line text field card on the right sidebar.

We'll use the following information:

TabFieldInput
SettingsDisplay NameGallery section title
SettingsAPI IDgallerySectionTitle
SettingsDescriptionAdd a title here
SettingsUse as title field checkboxSelect this checkbox

We'll click Add to save.

Next, we want the possibility to add multiple images to our gallery, so we'll add an Asset picker field that allows multiple values, using the following information:

TabFieldInput
SettingsDisplay NameImages
SettingsAPI IDimages
SettingsDescriptionAdd your images
SettingsField optionsSelect the Allow multiple assets checkbox

We'll click Add to save.

Now its time to add the enumerations we created earlier as enumeration fields.

We'll start with the aspect ratio enumeration. We'll find the Enumeration field on the Add fields sidebar, and click Add on the field card.

We'll use the following information:

TabFieldInput
SettingsDisplay NameImages aspect ratio
SettingsAPI IDimagesAspectRatio
SettingsEnumerationSelect "aspect ratio" from the dropdown menu
SettingsDescriptionSelect the aspect ratio for the images in this gallery

We'll click Add to save.

We'll follow the same steps to add the image size enumeration, using the following information:

TabFieldInput
SettingsDisplay NameImages size
SettingsAPI IDimagesSize
SettingsEnumerationSelect "Image size" from the dropdown menu
SettingsDescriptionSelect a size for the images in this gallery

We'll click Add to save.

Finally, we'll add a Number field, which will allow us to indicate how many columns the gallery should have. We'll find it on the Add fields right sidebar, click on it, and use the following information:

TabFieldInput
SettingsDisplay NameColumns
SettingsAPI IDcolumns
ValidationsLimit input range checkboxUse the dropdown to select Between and then add the values 2 and 4. In the Custom error message field, write "Please add a value between 2 and 4.".
AdvancedSet initial value checkboxSelect this checkbox and set the Initial value field to 2.

We'll click Add to save.

With this configuration, we ensure that the field has a default initial value, but also allows editors to write a value between 2 and 4 instead. This way, while we allow editors to input a numeric value, we also ensure that the value added falls within a range that we set.

This is how you create an image gallery component containing a title, an asset picker to add multiple images, dropdowns for format that will let you select a gallery aspect ratio as well as an image size, and a number field to set up the number of columns. Creating the gallery as a component allows you to reuse the structure in different models in your project.