Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

No Styles Output in Response on Custom Image Component #15

Closed
mortensassi opened this issue Jan 25, 2019 · 6 comments
Closed

No Styles Output in Response on Custom Image Component #15

mortensassi opened this issue Jan 25, 2019 · 6 comments

Comments

@mortensassi
Copy link

Like mentioned in LayoutComponents the styles won't get output in the response:

components.js

{
    "custom_image": {
        "label": "Custom Image",
        "dialog": "normal",
        "children": false,
        "fields": [
            {
                "name": "image",
                "label": "Image",
                "type": "asset",
                "default": "",
                "info": "",
                "group": "",
                "localize": false,
                "width": "1-1",
                "lst": true,
                "acl": [],
                "options": {
                    "styles": [
                        "Default",
                        "Placeholder"
                    ]
                }
            }
        ],
        "group": "media"
    }
}

Response

{
          "component": "custom_image",
          "settings": {
            "id": "",
            "class": "",
            "style": "",
            "image": {
              "path": "\/2019\/01\/24\/5c49eeada1071slide5.jpg",
              "title": "slide5.jpg",
              "mime": "image\/jpeg",
              "description": "",
              "tags": [],
              "size": 262747,
              "image": true,
              "video": false,
              "audio": false,
              "archive": false,
              "document": false,
              "code": false,
              "created": 1548349101,
              "modified": 1548351106,
              "_by": "5c49dd3c3361356bf0000243",
              "width": 1600,
              "height": 1069,
              "colors": [
                "#cbcbcb",
                "#272727",
                "#585858",
                "#7a7a7a",
                "#646464"
              ],
              "folder": "",
              "_id": "5c49eeae34366200290003b1"
            }
          }
        }
@pauloamgomes
Copy link
Owner

Hey @mortensassi , it should be working now, please confirm.

@mortensassi
Copy link
Author

mortensassi commented Feb 4, 2019

Downloaded the new code but no changes.

Edit: Played around and found out that if you create an asset/image field in a collection and extend its options, you get an correct output. Seems to be an issue with custom components i guess @pauloamgomes

@pauloamgomes
Copy link
Owner

Yeah, I did some changes to handle better the components but forgot to handle a previous check where I dig into the collection fields to avoid being running code when is not required. Think now it should be working well.

@mortensassi
Copy link
Author

Great it works – Thank you for your work! Only thing i've noticed that you don't need to pass the options in order to get the styles output – Not sure if this is intendend?

@pauloamgomes
Copy link
Owner

You mean, "options" inside the component field definition? The options are only required on nested fields, for example when you are defining an asset field inside a set:

{
  "fields": [
    {
      "type": "asset",
      "name": "myasset",
      "options": {
         "styles": ["style1", "style2"]
      }
    }
  ]
}

@mortensassi
Copy link
Author

Yes i meant that, okay now i do understand how it works – I'll close this issue since it's fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants