sleeping-owl / admin

Administrative interface builder for Laravel
http://sleeping-owl.github.io/
MIT License
504 stars 258 forks source link

Can't get to see thumbnail #129

Open mikamoush opened 9 years ago

mikamoush commented 9 years ago

Hi, I'm making an admin page for videos. In the list view (the default one) I want to display Thumbnail (which is a image file uploaded by the user in the form), the title and decription.

Form: video

ListView: video2

As you can see, the image is not displayed at all. Here is the code:

Models/Video.php

use Illuminate\Database\Eloquent\Model;
use SleepingOwl\Models\Interfaces\ModelWithFileFieldsInterface;
use SleepingOwl\Models\Interfaces\ModelWithImageFieldsInterface;
use SleepingOwl\Models\SleepingOwlModel;
use SleepingOwl\Models\Traits\ModelWithImageOrFileFieldsTrait;

class Video extends SleepingOwlModel implements ModelWithFileFieldsInterface, ModelWithImageFieldsInterface
{
    use ModelWithImageOrFileFieldsTrait;
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'videos';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['title', 'description', 'thumbnail', 'category'];

    public function category()
    {
        return $this->belongsTo('App\Models\Category');
    }

    public function tags()
    {
        return $this->belongsToMany('App\Models\Tag');
    }

    public function getImageFields()
    {
        return [
            'thumbnail' => '/uploads',
        ];
    }
}

Model for Sleeping OWl Admin admin/Video.php

use SleepingOwl\Admin\Admin;
use SleepingOwl\Admin\Columns\Column;
use SleepingOwl\Admin\Models\Form\FormItem;

Admin::model('\App\Models\Video')->title('Videos')->as('videos')->columns(function () {
    Column::image('thumbnail', Lang::get('video.thumbnail'));
    Column::string('title', Lang::get('video.title'));
    Column::string('description', Lang::get('video.description'));
})->form(function () {
    FormItem::text('title', Lang::get('video.title'));
    FormItem::textarea('description', Lang::get('video.description'));
    FormItem::image('thumbnail', Lang::get('video.thumbnail'));
});

Is there something wrong with my config ?

noxify commented 9 years ago

Is your uploaded image in the uploads directory?

sudo-ryan commented 9 years ago

I have the same issue - image is uploaded to the correct location (and filename added to db) but the view doesn't display the image, nor does the model table view.

sudo-ryan commented 9 years ago

This occurs in the 4.2 version too.

mikamoush commented 9 years ago

The image is in the uploads directory. Plus, when I display it into my front view it works... Its's only in the default admin view

sudo-ryan commented 9 years ago

Have you added 'imagecache' to the route string within config/imagecache.php ?

mikamoush commented 9 years ago

I just did, and same result...

sudo-ryan commented 9 years ago

Can you access (and display an image) from the original image links generated through the image/all route?

mikamoush commented 9 years ago

Yes it's displayed

sudo-ryan commented 9 years ago

In your image method in your model that defines the image location, try setting it to:

['yourImageField' => ''];

And check admin

mikamoush commented 9 years ago

I just noticed I didnt write Column::image but string ... Sorry and thanks for your help. Resolved

nunomazer commented 9 years ago

@mikaben89 if it's resolved you can mark this issue as closed, thanks