ProductImages
Query, Update and Delete Product Images
View-Specific Information
The server uses the Shopify API to process search criteria that refer to the ProductId and ImageId. The supported SQL operators are '=' for ProductId and '=' for ImageId. The server processes other filters client-side within the server. For example, the following queries are processed server-side.Select
SELECT * FROM ProductImages WHERE ProductId = '123'
SELECT * FROM ProductImages WHERE ProductId = '123' AND ImageId = '2342'
Insert
To create a new product image with image data as attachment
INSERT INTO ProductImages (productid, filename, attachment) VALUES ('64146735127', 'test.png', 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==')")
To create a new product image using a source URL that will be downloaded by Shopify
INSERT INTO ProductImages (productid, filepath) VALUES ('64146735127', 'http://example.com/rails_logo.gif')")
To create a new product image and make it the main image
INSERT INTO ProductImages (productid, position, filename, filepath) VALUES ('64146735127', 1, 'test.png', 'http://example.com/rails_logo.gif')")
To create a new product image and attach it to product variants
INSERT INTO ProductImages (productid, variantids, filename, attachment) VALUES ('64146735127', '[808950810,457924702]', 'test.png', 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==')")
Update
To update a product image you must specify its ProductId and ImageId.
To change the position and alt tag content for an image
UPDATE ProductImages SET Position = 1, Alt = 'This is the main image' WHERE ProductId = '123' AND ImageId = '2342'
To add it to product variants for an image
UPDATE ProductImages SET VariantIds = '[808950810,457924702]' WHERE ProductId = '123' AND ImageId = '2342'
Delete
To delete a product image you must specify its Id.
DELETE FROM ProductImages WHERE ProductId = '123' AND ImageId = '2342'
Columns
| Name | Type | ReadOnly | References | Description |
| ImageId [KEY] | Long | True |
A unique numeric identifier for the product image. | |
| ProductId | Long | True |
Products.Id |
The id of the product associated with the image. |
| VariantIds | String | False |
The array of variant ids associated with the image. | |
| Position | Int | False |
The order of the product image in the list. | |
| FilePath | String | False |
Full path to the image. Can be locally or online. Example: http://example.com/rails_logo.gif. Either this or Base64Content are required. | |
| Width | Int | True |
The width of the image. | |
| Height | Int | True |
The height of the image. | |
| CreatedAt | Datetime | True |
The datetime when the image was created. | |
| UpdatedAt | Datetime | True |
The datetime when the image was updated. | |
| Alt | String | False |
The Alt content of the image. | |
| Src | String | False |
Specifies the location of the product image. This parameter supports URL filters that you can use to retrieve modified copies of the image. |
Pseudo-Columns
Pseudo-columns are fields that can only be used in the types of statements under which they are explicitly listed. They are not standard columns but instead provide additional functionality for specific operations.
| Name | Type | Description |
| FileName | String |
The name that the image will be displayed in the application. |
| Attachment | String |
Base64 encoded bytes of the image. Either this or FilePath are required. |