This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

cageman
cageman

I have created a plugin and I would like to use the media manager in order to select an image and to save the file path in my model. I have added

featured_image: label: trt.events::lang.models.event.featured_image type: mediafinder mode: file

to my fields.yaml file. In the back-end I am able to open the media manager and to select an image. However, I can't figure out how to save the file path. In my model class I am using this code.

public $attachOne = [ 'featured_image' => ['System\Models\File'] ];

I guess the above code is incorrect but I can't find any other references. Any help would be really appreciated. Thank you.

alxy
alxy

You dont need to setup the $attachOne relation, this is used by the fileupload form widget.

Remove it and instead add a text/string column featured_image to your table. That will contain a relative path to the image once you select an image using the Media Manager.

cageman
cageman

Thanks. It is working now.

KurtJensen
KurtJensen

When I want to display and image from the fileupload form widget, how do I do that?

Can I crop it before it is served to a http request?

Last updated

Crazymodder
Crazymodder

Yes you can.

Try somethink like this

{{item.image.thumb(800,600,{'mode':'crop'})}}

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.