Giter Site home page Giter Site logo

jameslkingsley / nova-media-library Goto Github PK

View Code? Open in Web Editor NEW
40.0 40.0 5.0 230 KB

A Laravel Nova field for displaying and updating a Spatie Media Library model.

Vue 56.31% JavaScript 2.89% CSS 0.06% PHP 40.74%
laravel library media nova spatie

nova-media-library's People

Contributors

ebess avatar elhebert avatar jameslkingsley avatar ragingdave avatar rahman95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nova-media-library's Issues

Queue Jobs trigger before the model is created

It seems that the queue jobs for the conversions/responsive are potentially run before the model gets created. My assumption is that the queue job gets kicked off and ran before the final save of the model is performed, so maybe it's just that the fillFromAttribute needs to use the saved model event rather than just adding the asset to the collection.

SVG refused

I defined one of my Mediacollections to allow svg:s.
When I try to upload an svg I get the error; "must be an image".

$this->addMediaCollection('logo')
            ->singleFile()
            ->acceptsFile(function (File $file) {
                return in_array($file->mimeType, ['image/jpeg', 'image/png', 'image/gif', 'image/tiff', 'image/webp', 'image/svg+xml']);
            });

Delete button

Hey,
nice field, very usefull! Sadly, the delete button is not shown.

Support Nova Image Cropper

And is it possible to add nova cropper which is already available and live preview when user upload image

Must be an image when updating a resource.

I checked the code because I couldn't update a resource without adding a picture every time I update the resource. Shouldn't the method within fillAttributeFromRequest be surrounded with something like this?

if (isset($request[$requestAttribute]) && !empty($request[$requestAttribute])) {
...
}

#4

Don't force the Media resource

IMHO, I don't think it's good practice to include the Media resource in the package's service provider.
It should be up to the user to decide whether or not they want it.

I personally don't very much care for this package's Media resource to show up in the navigation.

Maybe remove it from the service provider and include instructions in the readme for those that want it...

Ability to add other attachment like PDF, mp4?

I think laravel medialibrary if for handling media not just image. So I think we can support it and just display appropriate thumbnail like pdf icon for pdf etc ?

And thanks for this awesome package :)

Images::make() not displaying anything

This is the code in my nova model

public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),

            Images::make(),
        ];
 }

This is my laravel model

class Event extends Model implements HasMedia
{
    use SoftDeletes, FullTextSearch, HasMediaTrait;
}

I can see the images using the getMedia method on my laravel model.

Image field needs a value to allow the form to be submitted

When trying to create or update a resource without submitting an image (thus with an empty Image field), nothing happen and I got this error in the console:

Unhandled promise rejection TypeError: "e.t0.response is undefined, can't access property "status" of it"

My code looks like this:

Image::make('Logo')
    ->usingConversion('optimized')
    ->toMediaCollection('logo'),

Any idea on what could cause this?

Media::hasGeneratedConversion() must be string, not array.

I was unable to load index view after adding "nova-media-library" fields to my resource.
Got this error:
image

Solved it by changing row 87 in Image.php from this:

$conversion = $this->meta()['usingConversion'] ?? [];

To this:

$conversion = $this->meta()['usingConversion'] ?? '';

Unable to save/update when using method withCustomProperties()

Your documentation says I can call any media-library method on a field.
Trying to use ->withCustomProperties() results in the following error:
image

In my nova resource:

Image::make('Logo', 'logo')
            ->withCustomProperties([
                'team_id' => $request->user()->current_team_id,
                'user_id' => $request->user()->id
            ])->hideFromIndex(),
Image::make('Banner', 'banner')
            ->withCustomProperties([
                'team_id' => $request->user()->current_team_id,
                'user_id' => $request->user()->id
            ])->hideFromIndex(),

question

not quite understand the principle of work.

I have photoreports, every photo report has a set of photographs.

in the photoreports I add:
use Kingsley \ NovaMediaLibrary \ Fields \ Images;
and in the field function:
Images :: make ('photos'),

it turns out something like that.
default

what am I doing wrong?

Issue with Single File Upload In Safari

Hello,

I'm using your package to attach a single file (that is not an image) to a resource.
As mentioned in the docs, I use Kingsley\NovaMediaLibrary\Fields\File

It works well in chrome, but in safari, an error appears when trying to submit the form and save the model.

This problem appears on Safari, with the Kingsley\NovaMediaLibrary\Fields\File field.
I've tried without the field and everything works fine so it definitely comes from this field.

The error is the following:

screenshot 2019-01-11 at 01 29 22

Thanks in advance for your help

Help regarding example

Suppose we want to have two types of file one is video and another is cover image for that video. So we would like to store cover image as cover image collection and video as video collection so that we can query it easily later. And each model can have only 1 cover image and only 1 video no more than that how would we accomplish it?

I tried like this:

            File::make('Video'),

            Image::make('Cover Image')
                ->usingConversion('thumb')
                ->preservingOriginal()
                ->toMediaCollection('cover_image'),

according to read me we can use public function registerMediaCollections() but it will be problematic if we got two media isn't it?

Unknown column 'preview_url' in 'field list

I am using your package and it works on edit screen, but not on index or detail view. I get

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'preview_url' in 'field list' (SQL: update media set updated_at = 2018-09-24 08:45:20, preview_url = http://www.test.local/storage/2030/conversions/amsterdam-panorama-thumb.jpg whereid= 2030)

Image::make('Panorama-Bild', 'panorama')
    ->usingConversion('thumb')
    ->preservingOriginal(),

Problem when creating/editing

When i add a new image or change an image on a resource I get two errors.

First:
image

Then when I try to save/update a second time:
image

Translation of $group label, ignored

Translated value $group of the nova media resource is ignored.

Added the key to the json language file.

class Media extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = \Spatie\MediaLibrary\Models\Media::class;
    public static $group = 'Attachements';

sv.json
"Attachements": "Bilagor"

How can I downlaod the uploaded file from the details page

Hi,
@jameslkingsley @ebess
I used File field for upload the pdf file with this package. The upload process is working fine, In the view page, it also shows me the name of the uploaded file. but how can I get the download button as the default File field offers?
here is the code
use Kingsley\NovaMediaLibrary\Fields\File;
...
File::make('File', 'activity_attachment');
...

As per Laravel nova File field, if I used "storeOriginalName" this method with the File field then it can automatically show the download button.

Single Image handling

I am finding the 'collection' approach to single image handling strange.

If I have a model with multiple image fields, and I want them to all only allow a single image per field, I have to make a bunch of different collections? This makes no sense to me, since I want all the image fields to draw from the same collection, but not to allow each individual field to select more than one item from the collection in question.

Am I just misunderstanding the docs, or is creating a bunch of separate collections the only way make a model have multiple single selection only image fields?

Only first ever uploaded image is used

Hi, i like this field very much.

On my fresh installed system i have the behaviour that only the first ever uploaded image per Object is displayed.

I have changed the fillAttributeFromRequest so any collection for this model is cleared before a new one is added.
Is this a Bug or am i doing / did understand something wrong?

...
$model->clearMediaCollection('myCollectionName');
$query = $model->addMedia($request[$requestAttribute]);
...

Best regards, Alex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.