Product Gallery Widget
Is it possible to use the product gallery widget to display all the images inside a folder?
-
Hi Priyanka,
The Product Gallery Widget currently doesn't support passing a folder so that it can display all assets inside it.
However, the Product Gallery Widget allows you to pass a list of public_ids to display or to display all assets with a shared tag. This means that there are two main ways you can show all assets from inside a folder in the Product Gallery Widget.
The first approach would be to have your backend server call the Admin API's get resources method and pass a 'prefix' parameter set to the folder you wish to get the list of assets from. The response to this method call would be a list of assets from the specified folder. What you can do is pull this list of assets, grab the public_ids from the response and send that list of public_ids to your frontend. Then pass those public_ids to the Product Gallery Widget.
The second approach would rely on tags. What you can do is tag all assets in a specific folder with a given tag. That can be done for already uploaded resources via the Media Library UI or API (by listing the resources with prefix as in the above example and using the tags method). Alternatively, you can set the tags at the time you are uploading your resources. Once the assets inside the folder have been given a tag, you can pass that tag when creating the Product Gallery Widget and the Widget would automatically pull the images with this tag and display them. Note that if you use this approach you should ensure the "Resource List" option from the Settings -> Security tab in your account is unchecked.
1
Post is closed for comments.
Comments
1 comment