Download the PHP package saad/laravel-model-images without Composer

On this page you can find all versions of the php package saad/laravel-model-images. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-model-images

Model Images

License

this package make saving (uploading or from storage) images with any set of dimensions and attachs them to you model is very easy just a few lines of code
for any customizations also have the full control of saving process

Dependencies

this library uses two providers one of intervention/image library and the other saad/image (My Package) for image manipulation the default provider is my package (saad/image) but you can switch between them as you wish and also you can create your own driver if you wish and use it.

Install

Basic Usage

1- Model Setup

2- Store Images:

Now to set user profile image, assume in profile controller we have a method called uploadUserProfile responds to upload image request, and another method setUserProfile to set profile image from storage image file

3- Public link

OK, for now we stored our user profile image, so how we can get our user profile image public link
this is very easy just use $user->getImagePublicLink() it will get profile photo url
by default all images will be stored inside public directory in the following directory images/uploads

this library uses the convention naming getImageFieldPublicLink()
so if we have image field called profile_photo the method will be getProfilePhotoPublicLink()

Customization


1- Multiple image sizes:

to set custom sizes like thumbnails or different dimensions for your uploaded images all you need is to define imageFieldImageSizes() method on your model

Get Public links
$user->getImagePublicLink() => for 512x512
$user->getImagePublicLink('256x256') => for 256x256
$user->getImagePublicLink('46x46') => for 46x46

Or yo can use general method getPublicLink($field)
$user->getPublicLink('image') => for 512x512
$user->getPublicLink('image', '256x256') => for 256x256
$user->getPublicLink('image', '46x46') => for 46x46

2- Custom save directory:

to set custom save directory (within public folder) define method

imageGeneralSavePath() this method will set save path for all model image fields

imageFieldNameSavePath the naming convention used to set different paths for each field

3- Custom save options:

you can control saving format, quality and png filters by defining those methods:

imageSaveExtension() defines image format default jpg
imageSaveQuality() defines image quality default 70 for jpg

for jpg quality will be from 0 to 100 low to high quality
for png quality will be from 0 to 9 high to low quality

imagePNGFilter() defines png image filter default PNG_NO_FILTER

4- Custom save provider:

this package shipped with two image manipulation providers:

Providers:
SaadImageProvider this is the default provider, it uses my image package saad/image for image manipulation process
InterventionImageProvider provider for famous package intervention/image for image manipulation process

Define Custom Provider:
you can define your custom provider class by implementing this interface Saad\ModelImages\Contracts\ImageProviderContract

Change Provider
you can change driver be defining imageSaveProvider() method in your model, which should return the provider instance.

Note:

There are difference between how intervention and my image library handle resizing images when width and height are defined and differs from original aspect

saad/image resize images to new dimensions by centering original image then resize and crop if necessary

intervention/image will stretch image to new size or will preserve aspect so it will respect one dimension and auto set the other according to original aspect

if this note is not clear, you can try both providers and see.

4- Default image:

Each model image field should have a default image, so consider the following cases:

1-Record does not have image when we try to get an image for a record which does not have an image attached yet

2- Record has image but file deleted or not exists when we try to get an image for a record but this image file is deleted or not exists

for these reasons we should define default image for each field, and this package will automatically return this default image if one of the previous cases happens

To set Default Image: defining a default image is the same process as attaching image to the model, the only difference is we tell the model that we are defining default image
by calling the static method settingDefaultImage() on the model ex: User::settingDefaultImage()
here we can see in action:


All versions of laravel-model-images with dependencies

PHP Build Version
Package Version
Requires saad/image Version ^1.0
intervention/image Version ^2.4@dev
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package saad/laravel-model-images contains the following files

Loading the files please wait ....