Queries Library
Queries LibraryExtract all image URLs from a Bricks page

Extract all image URLs from a Bricks page

This query extracts all image URLs from a Bricks page, from all the contained image elements.

This query requires the Bricks extension to be enabled.

The query requires the following variable:

  • $customPostId: The ID of the Bricks custom post to analyze
query GetBricksImageURLs($customPostId: ID!) {
  customPost(by:{ id: $customPostId }, status: any) {
    id
    title
    bricksData(filterBy: { include: ["image"] })
      @underEachArrayItem(
        passValueOnwardsAs: "elementJSON"
        affectDirectivesUnderPos: [1, 2]
      )
        @applyField(
          name: "_objectProperty",
          arguments: {
            object: $elementJSON,
            by: { path: "settings.image.url" }
          },
          passOnwardsAs: "imageURL"
        )
        @applyField(
          name: "_echo",
          arguments: {
            value: $imageURL
          }
          setResultInResponse: true
        )
  }
}