graker / oc-photoalbums-plugin

Photo albums plugin for OctoberCMS
MIT License
12 stars 8 forks source link

Photos Controller in Album with new fields #7

Closed Nvironmental closed 5 years ago

Nvironmental commented 5 years ago

Hi there, I have extended your plugin by adding some custom fields to photo model. This works and I can successfully added my details to the fields however, these fields are not visible when I try to edit the photo from photo list present in the album.

can you guys help me how can I extend the view of the added fields in Albums too.

Thanks

graker commented 5 years ago

Hi

Photo list and edit form are available in the album controller via Relation manager, you can check out controllers/albums/config_relation.yaml. So I guess it is up to Relation manager controller to pick up your additional fields. I'm not sure whether it can do it or not.

Nvironmental commented 5 years ago

Hi Graker, Thanks for your prompt response. Let me check on to this and get back with you.

Nvironmental commented 5 years ago

Hi Graker,

I solved it by using Event::listen('backend.form.extendFieldsBefore', function($widget) {}

I wanted to ask, when accessing [albumList.latestPhoto.thumb] this gives me a cropped photo on the frontend, how can I get the exact dimensions of the images.

graker commented 5 years ago

latestPhoto is a relation on each album returning a Photo model of either most recent picture or the one specifically selected as "front" in album settings. So with it being a Photo model, you can access the image through latestPhoto.image as $photo->image is a usual October image file model. So you can get full path to the image using latestPhoto.image.path.