jameslkingsley / nova-media-library Goto Github PK
View Code? Open in Web Editor NEWA Laravel Nova field for displaying and updating a Spatie Media Library model.
A Laravel Nova field for displaying and updating a Spatie Media Library model.
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.
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']);
});
Hey,
nice field, very usefull! Sadly, the delete button is not shown.
And is it possible to add nova cropper which is already available and live preview when user upload image
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])) {
...
}
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...
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 :)
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.
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?
Hi,
Is there a way to upload multiple images via Image
field?
Your documentation says I can call any media-library method on a field.
Trying to use ->withCustomProperties() results in the following error:
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(),
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:
Thanks in advance for your help
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?
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 where
id= 2030)
Image::make('Panorama-Bild', 'panorama')
->usingConversion('thumb')
->preservingOriginal(),
Media was successfully added but when loading the index page it would fail and not load
#20 I had a look at this issue and was able to fix it with the fix mentioned. It was supposed be fixed on version 1.4.0 according to that post but isnt
Regards
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"
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.
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?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.