Cockpit: Focal Point not working, if not the full url path to the image

Created on 9 Nov 2018  路  4Comments  路  Source: agentejo/cockpit

I have an vertical image and I set the focal point in the asset interface to the top, because the face is in the top section of the image.

I need to create a square thumbnail image. To generate the thumbnail I use https://example.com/api/cockpit/image and the direct output o=1.

The collection returns a relative path to the image like /storage/uploads/2018/10/04/image.jpg. So this must be the url to the thumb (of course... src url encoded):

https://example.com/api/cockpit/image?token=XXX&q=80&w=200&h=200&m=thumbnail&src=/storage/uploads/2018/10/04/image.jpg&o=1

But this url does not affected the focal point. If i add the full path of cockpit to the src, it works:

https://example.com/api/cockpit/image?token=XXX&q=80&w=200&h=200&m=thumbnail&src=https://example.com/storage/uploads/2018/10/04/image.jpg&o=1

It seems, that cockpit does not recognize that the image is an asset:

https://github.com/agentejo/cockpit/blob/2d79c26856799f179ef91d776165d1867e430b35/modules/Cockpit/bootstrap.php#L125

With relative path to the asset $fp is always center

https://github.com/agentejo/cockpit/blob/2d79c26856799f179ef91d776165d1867e430b35/modules/Cockpit/bootstrap.php#L227

Most helpful comment

if you're using assets, then please use the asset _id as src e.g:

https://example.com/api/cockpit/image?token=XXX&q=80&w=200&h=200&m=thumbnail&src=5a00e80002ac8doc1362529026&o=1

cockpit then also get the focal point settings

All 4 comments

if you're using assets, then please use the asset _id as src e.g:

https://example.com/api/cockpit/image?token=XXX&q=80&w=200&h=200&m=thumbnail&src=5a00e80002ac8doc1362529026&o=1

cockpit then also get the focal point settings

if you're using assets, then please use the asset _id as src e.g:

https://example.com/api/cockpit/image?token=XXX&q=80&w=200&h=200&m=thumbnail&src=5a00e80002ac8doc1362529026&o=1

cockpit then also get the focal point settings

That's great @aheinze , was not aware that fp would be handled by the thumbnail function automatically.
Updated the image styles addon so when generating styles for assets they will take the fp in consideration.

Think the asset field could be improved by providing a quick way to access the asset details (and set there the focal point), or at least provide some events that can handled:

image

otherwise, you need to click on replace and use the edit from the listing
what do you think?

@pauloamgomes yes, I think that would be a great improvement. I'll add it to my todo list

@aheinze I did something on PR #921 that extracts the editing functionality from cp-assets into cp-asset, so it can be reused in the field. From my tests, it seems to work well, but kindly review and see if that make sense.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HausOfAlejandro picture HausOfAlejandro  路  4Comments

dragosdydy picture dragosdydy  路  3Comments

elpeyotl picture elpeyotl  路  3Comments

gryphonmyers picture gryphonmyers  路  6Comments

AienTech picture AienTech  路  3Comments