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

lenrsmith
lenrsmith

I am working on a custom extension to the RainLab.Blog plugin. I added some custom file uploads and decided that it would be nice to use the Media Manager. I have the following in my plugins boot() method:

            $widget->addFields([
                'banner_image'=>[
                    'tab'=>'Images',
                    'label'=>'Banner Image',
                    'type'=>'mediafinder',
                    'mode'=>'image',
                    'imageWidth'=>700,
                    'imageHeight'=>220
                ],
                ...

This works great at first, but when the backend page is refreshed, the image path is shown but not the image. Any thoughts?

philipptempel
philipptempel

Did you also extend the blog post model? If not, then you will only have a field for the banner image in your form but no related model property to save it to. I could imagine that this might lead to problems.

lenrsmith
lenrsmith

There is no issue with it saving the data. Whenever I first add an image in the backend post form, the image displays on the page. When I refresh, the image is gone and the relative path information is displayed: storage/app/uploads/public/574/873/85e/57487385e0d62037531604.jpg

On the fronted, the image displays as I would expect.

SnipiBA
SnipiBA

lenrsmith said:

There is no issue with it saving the data. Whenever I first add an image in the backend post form, the image displays on the page. When I refresh, the image is gone and the relative path information is displayed: storage/app/uploads/public/574/873/85e/57487385e0d62037531604.jpg

On the fronted, the image displays as I would expect.

thats okay, but u need to create a migration to append new database field to blog_posts table, where was stored that path to picked file. maybe you can change mediafinder to upload, and extend blogpost with attachOne.

1-4 of 4

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