statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
32 stars 1 forks source link

Ability to hook into the Asset fieldtype #80

Open edalzell opened 4 years ago

edalzell commented 4 years ago
Create Entry ‹ Posts ‹ Collections ‹ Statamic 2020-02-10 09-19-02

Got this from a potential client:

To be on the safe side I'll repeat what I wrote on Discord; The thing is we're working on a SaaS project based partially on Statamic, and during usertesting we noticed a lot of the users had problems with images. They do not have a proper image editor installed and finds it difficult to use online services for image cropping. So we would like to investigate the possibility of including cropping as a functionality in Statamic.

The only thing we actually need is basic cropping, and if the crop could also expand the image with a predefined background color if needed it would be a bonus. So you could make a portrait floor plan to landscape without cropping top/bottom as an example. I've been looking at https://pqina.nl/doka/ and found it quite interesting, but I'm not sure if it's a dead-end.

Would be super great if we could hook into the asset "panel".

jasonvarga commented 4 years ago

A workaround for now could be to create it as a fieldtype, and place it in the asset blueprint.

edalzell commented 4 years ago

Yup, looking into that now.

edalzell commented 4 years ago

@jasonvarga how can I reference another field from my fieldtype? I'll need to access the asset.

jasonvarga commented 4 years ago

$this->field()->parent() should be the Asset

edalzell commented 4 years ago

in JS? I'll need it on the front end to init the cropping.

jasonvarga commented 4 years ago

Pass along whatever you need from php to js by preloading meta data. https://statamic.dev/extending/fieldtypes#meta-data

skylennard commented 3 years ago

I have a use case for this: control the private/public permission for a file on our CDN, on a file-by-file basis.