Download the PHP package sergmoro1/laravel-imageable without Composer
On this page you can find all versions of the php package sergmoro1/laravel-imageable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sergmoro1/laravel-imageable
More information about sergmoro1/laravel-imageable
Files in sergmoro1/laravel-imageable
Package laravel-imageable
Short Description The ability to upload multiple images to any model
License MIT
Informations about the package laravel-imageable
Laravel Imageable
The Imageable
package allows quickly and easily to enable image uploading for any model.
Uploading files, processing them, and saving them to the desired storage is taken over by Imageable
.
Besides each image may have some descriptive fields associated with it.
API
The Imageable
package uses the API
to download, process and save files. Therefore,
authentication is required for the package to work. By default, basic
stateless authentication is used to pass tests and make to a quick start.
Changes
Tailwindcss
is used in Imageable
by default, as in the Laravel
.
Since css
, js
, views
resources are published after installing the package, it is possible to change templates and
customize interface elements.
Limitation of use
Only one component <x-imageable-upload />
can be placed on the page.
Installation
Run migration
Publish resources
Usage
For ability images uploading add HasStorage
, HasImages
traits to the model.
Insert upload component in a view.
Please note that the component uses an instance of the model, therefore, it must be available in the template.
The limit
parameter defines the number of images that can be uploaded for the model. The default is 0
, which means you can upload any number of images.
If the necessary css
and js
files are already connected to the page, and this is possible if you have already connected Imageable
for another model, then you can upload images.
JS libs & plugins
Add in dependencies
section of the package.json
file two lines
Then run in the console
CSS
In a file resources/css/app.css
, after lines
add line
If necessary, you can make adjustments to the classes definition in the resources/css/imageable/upload.css
file
since this is a copy of a similar package file.
JS
To upload images and work with additional fields related to images, add two lines to app.js
.
If you want to upload more than one file for a specific model, you can add a plugin for sorting of images Sortable. This is important when you want to change the order of image output in frontend or want to use the first image as the main image. Sorting is performed by drag & drop the mouse. Add a line below for images sorting to app.js
.
CSS placement
The Imageable
package uses Google Material Icons
, so you need to connect the icons to the page.
For example in views/layouts/app.blade.php
.
JS placement
Since the Imageable
package uses the API
to upload files, authentication is required.
By default, the package uses basic
stateless authentication to run tests and quickly start using the package.
Place the app_credentials
variable on the page. The variant of receiving credentials is yours.
Finally
Run in the project directory
Configuration
The storage parameters, the view of line associated with the uploaded file, the number and values of additional parameters can be changed.
Model
By default, the parameters for storing images are set
An empty path
parameter means that a subdirectory with the model name will be created on the selected disk. For example, storage/app/public/post
. The separately
parameter set to true
means that a separate directory will be created for each model with the Id
of the model as the name. For example, storage/app/public/post/1
.
Storage parameters can be changed according to the principles of Laravel file storage using the setStorage
method of the Sergmoro1\Imageable\Traits\HasStorage
class.
Only the caption
field is set as an additional field for each image. The list of fields, their order and default values can also be redefined using the setAddonDefaults()
method of the class Sergmoro1\Imageable\Traits\HasImages
.
Both methods must be called in the constructor of the corresponding model. For example, defining fields:
Views
After installing and publishing the package, the component files are copied to the resources\views\vendor\imageable
directory, where you can freely edit html markup, change styles and add/remove fields to describe each uploaded image.
Addon fields
To change the list of additional fields of uploaded images, you need to edit the default values in the addonDefaults
variable of the model, as mentioned above, and the vendor\imageable\line\fields.blade.php
view, where it is necessary to define additional html markup. An example with possible fields and their values is given in the package in the file fiealds-example.blade.php
.
If the list of additional fields varies from model to model, then the contents of the files line\fields.blade.php
should be different and therefore the file names should be different. The model variable $addonFieldsView
is used to specify the file name. The name can be anything, for example:
You need to copy the file vendor\imageable\line\fields.blade.php
to the file vendor\imageable\line\post-fields.blade.php
and make changes.
Tests
All versions of laravel-imageable with dependencies
illuminate/support Version ^8.1|^9.0|^10.0|^11.0
imagine/imagine Version ~0.5.0