Uploading Images

Hi Prismic team,

I would like to know if or how the current method is that a person can upload their slice preview images through the API.

The ability to POST a slice and also a custom type works well, but obviously it would be nice to be able to also push the previews.

Is this something planned for the API or only through the SM UI?


Also I think for some people the reason for an API 403 response is that the /slices/{slice_id} is case sensitive and only lower case characters work. So that is a bit misleading when requesting a Title cased Slice or Custom Type.

Hello @ReeceM, it is possible to add Custom screenshots through the Custom Types API to Slice Machine. You just need to include the imageUrl field inside of each Slice model. See this example:

curl --location --request POST 'https://customtypes.prismic.io/slices/insert' \
--header 'repository: tutorial-series' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjM2M3MTAzMTEwMDAwMWYwMGExYTZhMiIsInR5cGUiOiJ1c2VyIiwiZGF0ZSI6MTYxMzczNTY2NzIxNSwiaWF0IjoxNjEzNzM1NjY3fQ.Ex18_cuNtHes69me4pHQGLpiQ-OUbi42-qFxkZCG-yw' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id": "image_gallery",
  "type": "SharedSlice",
  "name": "ImageGallery",
  "description": "ImageGallery",
  "variations": [
    {
      "id": "default",
      "name": "Default",
      "docURL": "...",
      "version": "sktwi1xtmkfgx8626",
      "description": "Text",
      "primary": {
        "text": {
          "type": "StructuredText",
          "config": {
            "label": "Text",
            "placeholder": "Text with rich formatting",
            "allowTargetBlank": false,
            "multi": "paragraph"
          }
        }
      },
      "items": {},
      "imageUrl": "https://images.prismic.io/tutorial-series/shared-slices/image_gallery/preview.png"
    }
  ]
}'

Hi @Pau,

Thank you for the specific field that can be used.

What I am not clear on is the URL that is inserted there, would that be an image that is hosted on my own CDN / accessible via unauthed HTTP requests?

Just asking as that would clear up if it isn't possible to upload a screenshot to the "images.prismic.io" site.

Hello @ReeceM, the image in the URL is not a snapshot, the URL takes you to the location of your image in the CDN.