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

EZEE-3281: Variations are now returned for imageasset field type #56

Merged
merged 2 commits into from
Oct 13, 2020

Conversation

ViniTou
Copy link
Contributor

@ViniTou ViniTou commented Oct 9, 2020

Question Answer
JIRA issue EZP-3281
Type feature/improvement
Target version eZ Platform v3.2.0
BC breaks no
Tests pass yes
Doc needed yes

It is now possible to obtain variations array for imageasset fieldtype identical to image one, i.e.
GET /api/ezp/v2/content/objects/102/versions/1

{
    "Version": {
        "_media-type": "application\/vnd.ez.api.Version+json",
        "_href": "\/api\/ezp\/v2\/content\/objects\/102\/versions\/1",
        "VersionInfo": {
            "id": 672,
            "versionNo": 1,
            "status": "PUBLISHED",
            "modificationDate": "2020-10-07T12:16:34+00:00",
            "Creator": {
                "_media-type": "application\/vnd.ez.api.User+json",
                "_href": "\/api\/ezp\/v2\/user\/users\/14"
            },
            "creationDate": "2020-10-07T12:16:19+00:00",
            "initialLanguageCode": "eng-GB",
            "languageCodes": "eng-GB",
            "VersionTranslationInfo": {
                "_media-type": "application\/vnd.ez.api.VersionTranslationInfo+json",
                "Language": [
                    {
                        "languageCode": "eng-GB"
                    }
                ]
            },
            "names": {
                "value": [
                    {
                        "_languageCode": "eng-GB",
                        "#text": "js_meme_1.png"
                    }
                ]
            },
            "Content": {
                "_media-type": "application\/vnd.ez.api.ContentInfo+json",
                "_href": "\/api\/ezp\/v2\/content\/objects\/102"
            }
        },
        "Fields": {
            "field": [
                {
                    "id": 417,
                    "fieldDefinitionIdentifier": "new_ezimageasset_1",
                    "languageCode": "eng-GB",
                    "fieldTypeIdentifier": "ezimageasset",
                    "fieldValue": {
                        "destinationContentId": "94",
                        "alternativeText": null,
                        "source": null,
                        "variations": {
                            "ezplatform_admin_ui_profile_picture_user_menu": {
                                "href": "\/api\/ezp\/v2\/content\/binary\/images\/94-399-1\/variations\/ezplatform_admin_ui_profile_picture_user_menu"
                            },
                            "gallery": {
                                "href": "\/api\/ezp\/v2\/content\/binary\/images\/94-399-1\/variations\/gallery"
                            },
                            "large": {
                                "href": "\/api\/ezp\/v2\/content\/binary\/images\/94-399-1\/variations\/large"
                            },
                            "medium": {
                                "href": "\/api\/ezp\/v2\/content\/binary\/images\/94-399-1\/variations\/medium"
                            },
                            "reference": {
                                "href": "\/api\/ezp\/v2\/content\/binary\/images\/94-399-1\/variations\/reference"
                            },
                            "small": {
                                "href": "\/api\/ezp\/v2\/content\/binary\/images\/94-399-1\/variations\/small"
                            },
                            "tiny": {
                                "href": "\/api\/ezp\/v2\/content\/binary\/images\/94-399-1\/variations\/tiny"
                            }
                        }
                    }
                }
            ]
        },
        "Relations": {
            "_media-type": "application\/vnd.ez.api.RelationList+json",
            "_href": "\/api\/ezp\/v2\/content\/objects\/102\/versions\/1\/relations",
            "Relation": [
                {
                    "_media-type": "application\/vnd.ez.api.Relation+json",
                    "_href": "\/api\/ezp\/v2\/content\/objects\/102\/versions\/1\/relations\/34",
                    "SourceContent": {
                        "_media-type": "application\/vnd.ez.api.ContentInfo+json",
                        "_href": "\/api\/ezp\/v2\/content\/objects\/102"
                    },
                    "DestinationContent": {
                        "_media-type": "application\/vnd.ez.api.ContentInfo+json",
                        "_href": "\/api\/ezp\/v2\/content\/objects\/94"
                    },
                    "SourceFieldDefinitionIdentifier": "new_ezimageasset_1",
                    "RelationType": "ASSET"
                }
            ]
        },
        "Thumbnail": {
            "_media-type": "application\/vnd.ez.api.Thumbnail+json",
            "resource": "\/bundles\/ezplatformadminui\/img\/ez-icons.svg#image",
            "width": null,
            "height": null,
            "mimeType": "image\/svg+xml"
        }
    }
}

It is also possible to fetch variations with using ezimageasset fieldId and contentId and not that related to linked image.
GET /api/ezp/v2/content/binary/images/{contentId-with-used-image-asset}-{image-asset-field-id}/variations/medium

TODO:

  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

@ViniTou ViniTou force-pushed the ezp-32004-imageasset-variations branch from 92ef765 to 039395e Compare October 9, 2020 09:57
@ViniTou ViniTou force-pushed the ezp-32004-imageasset-variations branch from 039395e to a8235c6 Compare October 9, 2020 10:22
@lserwatka lserwatka merged commit 54f8f03 into master Oct 13, 2020
@lserwatka lserwatka deleted the ezp-32004-imageasset-variations branch October 13, 2020 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants