nth image from ACF Gallery in Bricks

A user asks:

Good day, do you have in Brickslabs any code available how I could get the second image of an ACF gallery within a Bricks dynamic shortcode?

This Pro tutorial shows how we can set up a custom function that can be called as a Bricks dynamic data tag whilst passing in the name of a Gallery-type of ACF Pro custom field and the number so that the specified nth image can be used as the source or background of an Image element.

After implementing the tutorial, to pull the second image of a page_gallery custom field for example:

{echo:bl_get_nth_image_from_gallery(page_gallery, 2)}

Step 1

Add the following in child theme's functions.php or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Instant access to 390+ Bricks code tutorials with BricksLabs Pro