Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alt member variable to Image tag. #286

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fixtures/image.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"updated_at": "2017-07-24T19:09:43-00:00",
"width": 123,
"height": 456,
"alt": "new alt tag content",
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1500937783",
"variant_ids": [
808950810,
Expand Down
2 changes: 2 additions & 0 deletions fixtures/images.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"updated_at": "2017-07-24T19:09:43-00:00",
"width": 123,
"height": 456,
"alt": "new alt tag content",
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1500937783",
"variant_ids": [
808950810,
Expand All @@ -22,6 +23,7 @@
"updated_at": "2017-07-24T19:09:43-04:00",
"width": 123,
"height": 456,
"alt": "new alt tag content 2",
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano-2.png?v=1500937783",
"variant_ids": [
]
Expand Down
1 change: 1 addition & 0 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Image struct {
Src string `json:"src,omitempty"`
Attachment string `json:"attachment,omitempty"`
Filename string `json:"filename,omitempty"`
Alt string `json:"alt,omitempty"`
VariantIds []uint64 `json:"variant_ids,omitempty"`
AdminGraphqlApiId string `json:"admin_graphql_api_id,omitempty"`
}
Expand Down
5 changes: 5 additions & 0 deletions image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func imageTests(t *testing.T, image Image) {
t.Errorf("Image.VariantIds[0] returned %+v, expected %+v", image.VariantIds[1], expectedVariantIds[1])
}

expectedAlt := "new alt tag content"
if image.Alt != expectedAlt {
t.Errorf("Image.Alt returned %+v, expected %+v", image.Alt, expectedSrc)
}

// Check that CreatedAt date is set
expectedCreatedAt := time.Date(2017, time.July, 24, 19, 9, 43, 0, time.UTC)
if !expectedCreatedAt.Equal(*image.CreatedAt) {
Expand Down
Loading