Photo Field Type | Yext Hitchhikers Platform
The Photo Field Type allows you to store photos directly on your entities.
The Photo Field Type is available to Custom Field Types as well as Custom Fields.
Field Definition
Field Model
The Photo Field type is composed of the following five properties:
Property | Description |
---|---|
width |
The width of the photo in pixels. |
height |
The height of the photo in pixels. |
url |
The Yext-Hosted URL of the file. |
sourceUrl |
Source URL of the file. Only populates if uploaded by providing a hosted URL. |
thumbnails (Legacy) |
Thumbnails of varying sizes generated upon upload. We suggest leveraging our new dynamic image serving rather than the pre-generated thumbnails. |
Available Validation
You can configure validation for Photo Custom Fields and Photo Custom Field Types at the field definition level and field type definition level. At this time, validation on Aspect Ratio, Width, and Height are available.
Option | Available Validation | Default | Accepted Valuess |
---|---|---|---|
Width | Set the minimum width in pixels | 0 | Whole numbers 0-1,000 |
Height | Set the minimum height in pixels | 0 | Whole numbers 0-1,000 |
Aspect Ratio | Set the accepted ratio of width to height | Unconstrained | Unconstrained, 1:1, 4:3, 3:2, 5:3, 16:9, 3:1,2:3, 5:7, 4:5, 16:10 |
Storing Photos
Photos can be stored using all interfaces where you edit your Knowledge Graph:
- Entity Edit with the Yext platform
- Entity Upload
- Data Connectors
- API
- Configuration as Code
All of those interfaces accept images as URLs referencing the image data already hosted somewhere. Only Customer Portal accepts image data directly, as a file that you upload from your computer.
Images must be smaller than 5 MB, and we accept a wide range of image formats: JPEG, PNG, BMP, GIF, TIFF, WEBP
Uploading Photos
To store a photo that is already being hosted, populate the hosted URL in the url
property. This provided url will then be propagated to the sourceUrl
property, while the url field will be the Yext hosted url of this file.
Updating Photos
If you want to change the photo that is being stored in a given photo field, update the value of the url
property to be the new hosted photo’s URL. Sending updates to the sourceUrl
property is not supported.
Accessing a Stored Image
Once an image has been stored, its hosted URL is kept as a reference in the Entity’s field. You can access your Entity via API to retrieve the photo’s URL directly, for example:
With other fields elided, the response looks like this:
{
"response": {
"entities": [{
"photoGallery": [{
"image": {
"width": 314,
"height": 366,
"url": "http://a.mktgcdn.com/p/Oua5ocwC7euaUFkJ-V8n3OpF76Xtfh_rdsDT9ki_laY/314x366.jpg"
}]
}]
}
}
Every image is assigned a long UUID (the long random string above), so the URL has the form: a.mktgcdn.com/p/UUID/WIDTHxHEIGHT.EXT
.
Both HTTP and HTTPS are supported.