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

Not fully supported when used by element-api plugin? #10

Open
bqkode opened this issue Feb 21, 2025 · 0 comments
Open

Not fully supported when used by element-api plugin? #10

bqkode opened this issue Feb 21, 2025 · 0 comments

Comments

@bqkode
Copy link

bqkode commented Feb 21, 2025

We're testing this plugin for a project where we use craft for content, but access it from a server by reading json provided by the element-api plugin. But it seems the url to the actual asset on cloudflare is missing?

The image is presented in the assets and preview in craft admin.

Example endpoint configuration in element-api.php:

'api/test.json' => function() {

            return [
                'elementType' => Entry::class,
                'paginate' => false,
                'contentType' => 'application/json',
                'criteria' => ['section' => 'testSection'],
                'transformer' => function(Entry $entry) {
                    return [
                        'image' => $entry->image->one(),
                    ];
                },
            ];
        },

example result:

{
  "data": [
    {
      "image": {
        "isFolder": false,
        "sourcePath": null,
        "folderId": 1,
        "uploaderId": 1,
        "folderPath": null,
        "kind": "image",
        "alt": null,
        "size": 240828,
        "keptFile": null,
        "dateModified": "2025-02-19T17:49:33+00:00",
        "newLocation": null,
        "locationError": null,
        "newFilename": null,
        "newFolderId": null,
        "tempFilePath": null,
        "suggestedFilename": null,
        "conflictingFilename": null,
        "deletedWithVolume": false,
        "eagerLoadInfo": null,
        "id": 5433,
        "tempId": null,
        "draftId": null,
        "revisionId": null,
        "isProvisionalDraft": false,
        "uid": "7cf575c8-cbfe-46e5-b01c-019e7c018dd5",
        "siteSettingsId": 5902,
        "fieldLayoutId": 5,
        "enabled": true,
        "archived": false,
        "siteId": 2,
        "title": "Test",
        "slug": null,
        "uri": null,
        "dateCreated": "2025-02-19T17:49:33+00:00",
        "dateUpdated": "2025-02-19T17:49:33+00:00",
        "dateLastMerged": null,
        "dateDeleted": null,
        "deletedWithOwner": null,
        "trashed": false,
        "isNewForSite": false,
        "forceSave": false,
        "canonicalId": 5433,
        "cpEditUrl": "<working url for editing image in craft>",
        "isDraft": false,
        "isRevision": false,
        "isUnpublishedDraft": false,
        "ref": null,
        "status": "enabled",
        "structureId": null,
        "url": null,
        "extension": "png",
        "filename": "29sfon_Hpht6AvIxBvVW5A.2bc1565c-ba01-4906-fef0-ea93f8de0300.Test.png",
        "focalPoint": {
          "x": 0.5,
          "y": 0.5
        },
        "hasFocalPoint": false,
        "height": 896,
        "mimeType": "image/png",
        "path": "29sfon_Hpht6AvIxBvVW5A.2bc1565c-ba01-4906-fef0-ea93f8de0300.Test.png",
        "volumeId": 1,
        "width": 750
      }
    }
  ]
}

Any tips, or is it possible to add support for this?
We'd really like to use this plugin, as it would work well with our setup - but if we're not able to get the actual url it's not usable for us unfortunately.

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

No branches or pull requests

1 participant