Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #3776

Closed
wants to merge 16 commits into from
Closed

WIP #3776

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ Move Larastan to dev deps

## 8.3.0 - 2020-06-11

- added `Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection`
- added `Programic\MediaLibrary\MediaCollections\Models\Collections\MediaCollection`

## 8.2.9 - 2020-06-08

Expand Down Expand Up @@ -1828,7 +1828,7 @@ Move Larastan to dev deps
- add the ability to store conversions on a separate disk
- simplify URL generation. You can now just use the `root` and `url` properties on a configured disk
- spatie/pdf-to-image is now a suggestion dependency, removing the need for always having to install ext-imagick
- added `shouldMatchBothExtensionsAndMimeTypes` to `Spatie\MediaLibrary\ImageGenerators\BaseGenerator`
- added `shouldMatchBothExtensionsAndMimeTypes` to `Programic\MediaLibrary\ImageGenerators\BaseGenerator`
- added progress bar on the clean command (#1623)
- the `UrlGenerator` interface now contains all required methods (#1656)
- use PHP 7.4 features where possible
Expand Down Expand Up @@ -1981,7 +1981,7 @@ To learn how to upgrade, take a look in UPGRADING.md

## 7.6.5 - 2019-07-16

- Support `jpeg` in `\Spatie\MediaLibrary\Conversion\Conversion::getResultExtension`
- Support `jpeg` in `\Programic\MediaLibrary\Conversion\Conversion::getResultExtension`

## 7.6.4 - 2019-07-15

Expand Down Expand Up @@ -2410,7 +2410,7 @@ To learn how to upgrade, take a look in UPGRADING.md
- remove `toCollection` and `toCollectionOnDisk` and `toMediaLibraryOnDisk`
- replace dependency on `spatie/laravel-glide` by `spatie/image`
- mime types will now be stored in the database so they can be queried even if files are stored on external filesystems
- rename `Spatie\MediaLibraryFilesystemInterface` to `Spatie\MediaLibrary\Filesystem\Filesystem`
- rename `Programic\MediaLibraryFilesystemInterface` to `Programic\MediaLibrary\Filesystem\Filesystem`
- remove `withCustomProperties`, `getNestedCustomProperty`, `setNestedCustomProperty`, `forgetNestedCustomProperty` and `hasNestedCustomProperty`
- drop support for Lumen and anything below Laravel 5.4
- clean up all classes
Expand Down Expand Up @@ -2844,7 +2844,7 @@ This version is a complete rewrite. Though there are lots of breaking changes mo

## 1.6.0

- Added: `Spatie\MediaLibrary\Models\Media::getHumanReadableFileSize()`
- Added: `Programic\MediaLibrary\Models\Media::getHumanReadableFileSize()`

## 1.5.6

Expand Down
36 changes: 18 additions & 18 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Because there are many breaking changes an upgrade is not that easy. There are m
## From v10 to v11

- Image v3 is now used. Make sure to update your image conversions to the new syntax. See [the image docs](https://spatie.be/docs/image/v3) for more info.
- All event names have gained the `Event` suffix. For example `Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAdded` is now `Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAddedEvent`.
- All event names have gained the `Event` suffix. For example `Programic\MediaLibrary\MediaCollections\Events\MediaHasBeenAdded` is now `Programic\MediaLibrary\MediaCollections\Events\MediaHasBeenAddedEvent`.


## From v9 to v10
Expand All @@ -24,7 +24,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Programic\MediaLibrary\MediaCollections\Models\Media;

class AddGeneratedConversionsToMediaTable extends Migration {
/**
Expand Down Expand Up @@ -75,44 +75,44 @@ class AddGeneratedConversionsToMediaTable extends Migration {
```

- rename `conversion_file_namer` key in the `media-library` config to `file_namer`. This will support both the conversions and responsive images from now on. More info [in our docs](https://spatie.be/docs/laravel-medialibrary/v9/advanced-usage/naming-generated-files).
- You will also need to change the value of this configuration key as the previous class was removed, the new default value is `Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer::class`
- You will also need to change the value of this configuration key as the previous class was removed, the new default value is `Programic\MediaLibrary\Support\FileNamer\DefaultFileNamer::class`
- in several releases of v8 config options were added. We recommend going over your config file in `config/media-library.php` and add any options that are present in the default config file that ships with this package.
- Media collection serialization has changed to support the newly introduced Media Library Pro components. If you are returning media collections directly from your controllers or serializing them to json manually then you can retain existing behaviour by setting `use_default_collection_serialization` to `true` inside `config/media-library.php`

## From v7 to v8

- internally the media library has been restructured and nearly all namespaces have changed. Class names remained the same. In your application code hunt to any usages of classes that start with `Spatie\MediaLibrary`. Take a look in the source code of medialibrary what the new namespace of the class is and use that.
- internally the media library has been restructured and nearly all namespaces have changed. Class names remained the same. In your application code hunt to any usages of classes that start with `Programic\MediaLibrary`. Take a look in the source code of medialibrary what the new namespace of the class is and use that.
- rename `config/medialibrary.php` to `config/media-library.php`
- update in `config/media-library.php` the `media_model` to `Spatie\MediaLibrary\MediaCollections\Models\Media::class`
- update in `config/media-library.php` the `media_model` to `Programic\MediaLibrary\MediaCollections\Models\Media::class`

- all medialibrary commands have been renamed from `medialibrary:xxx` to `media-library:xxx`. Make sure to update all media library commands in your console kernel.
- the `Spatie\MediaLibrary\HasMedia\HasMediaTrait` has been renamed to `Spatie\MediaLibrary\InteractsWithMedia`. Make sure to update this in all models that use media. Also make sure that they implement the `HasMedia` interface, see [Preparing your model](https://spatie.be/docs/laravel-medialibrary/v8/basic-usage/preparing-your-model).
- the `Programic\MediaLibrary\HasMedia\HasMediaTrait` has been renamed to `Programic\MediaLibrary\InteractsWithMedia`. Make sure to update this in all models that use media. Also make sure that they implement the `HasMedia` interface, see [Preparing your model](https://spatie.be/docs/laravel-medialibrary/v8/basic-usage/preparing-your-model).
- Add a `conversions_disk` field to the `media` table ( varchar 255 nullable; you'll find the definition in the migrations file of the package) and for each row copy the value of `disk` to `conversions_disk`.
- Add a `uuid` field to the `media` table ( char 36 nullable) and fill each row with a unique value, preferably a `uuid`

You can use this snippet (in e.g. tinker) to fill the `uuid` field:

```php
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Programic\MediaLibrary\MediaCollections\Models\Media;
Media::cursor()->each(
fn (Media $media) => $media->update(['uuid' => Str::uuid()])
);
```

- Url generation has been vastly simplified. You should set the `url_generator` in the `media-library` config file to `Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class`. It will be able to handle most disks.
- Url generation has been vastly simplified. You should set the `url_generator` in the `media-library` config file to `Programic\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class`. It will be able to handle most disks.
- remove the `s3.domain` key from the `media-library` config file
- spatie/pdf-to-image is now a suggestion dependency. Make sure to install it, if you want to create thumbnails for PDFs or SVGs
- `registerMediaConversions` and `registerMediaCollections` should now use the `void` return type.
- if the `path_generator` key in the `media-library` config file was set to `null`, change the value to `Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator::class`
- if the `url_generator` key in the `media-library` config file was set to `null`, change the value to `Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class`
- if the `path_generator` key in the `media-library` config file was set to `null`, change the value to `Programic\MediaLibrary\Support\PathGenerator\DefaultPathGenerator::class`
- if the `url_generator` key in the `media-library` config file was set to `null`, change the value to `Programic\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class`
- the `rawUrlEncodeFilename` method on `BaseUrlGenerator` has been removed. Remove all calls in your own code to this method.
- `getConversionFile` on `Conversion` now accepts a `Media` instance instead of a `string`. In normal circumstance you wouldn't have used this function directly.
- the default collection name for responsive images was changed from `medialibrary_original` to `media_library_original` which requires you to update the `responsive_images` column and rename all generated files with that collection name. This is an example migration of how to do that (**read through the code and make sure it does what you want**):
```php
use Illuminate\Contracts\Filesystem\Factory;
use Illuminate\Database\Migrations\Migration;
use App\Models\Media;
use Spatie\MediaLibrary\Support\PathGenerator\PathGeneratorFactory;
use Programic\MediaLibrary\Support\PathGenerator\PathGeneratorFactory;

class RenameResponsiveImagesCollectionNameInMedia extends Migration
{
Expand Down Expand Up @@ -208,11 +208,11 @@ If you want your own filesystem implementation, you should extend the `Filesyste
## From v6 to v7

- add the `responsive_images` column in the media table: `$table->json('responsive_images');`
- rename the `use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;` interface to `use Spatie\MediaLibrary\HasMedia\HasMedia;`
- rename the `use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;` interface to `use Spatie\MediaLibrary\HasMedia\HasMedia;` as well (the distinction was [removed](https://github.com/spatie/laravel-medialibrary/commit/48f371a7b10cc82bbee5b781ab8784acc5ad0fc3#diff-f12df6f7f30b5ee54d9ccc6e56e8f93e)).
- rename the `use Programic\MediaLibrary\HasMedia\Interfaces\HasMedia;` interface to `use Programic\MediaLibrary\HasMedia\HasMedia;`
- rename the `use Programic\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;` interface to `use Programic\MediaLibrary\HasMedia\HasMedia;` as well (the distinction was [removed](https://github.com/spatie/laravel-medialibrary/commit/48f371a7b10cc82bbee5b781ab8784acc5ad0fc3#diff-f12df6f7f30b5ee54d9ccc6e56e8f93e)).
- all converted files should now start with the name of the original file. One way to achieve this is to navigate to your storage/media folder and run `find -type d -name "conversions" -exec rm -rf {} \;` (bash) to remove all existing converted files and then run `php artisan medialibrary:regenerate` to automatically recreate them with the proper file names.
- `Spatie\MediaLibrary\Media` has been moved to `Spatie\MediaLibrary\Models\Media`. Update the namespace import of `Media` across your app
- The method definitions of `Spatie\MediaLibrary\Filesystem\Filesystem::add` and `Spatie\MediaLibrary\Filesystem\Filesystem::copyToMediaLibrary` are changed, they now use nullable string typehints for `$targetFileName` and `$type`.
- `Programic\MediaLibrary\Media` has been moved to `Programic\MediaLibrary\Models\Media`. Update the namespace import of `Media` across your app
- The method definitions of `Programic\MediaLibrary\Filesystem\Filesystem::add` and `Programic\MediaLibrary\Filesystem\Filesystem::copyToMediaLibrary` are changed, they now use nullable string typehints for `$targetFileName` and `$type`.

## From v5 to v6

Expand Down Expand Up @@ -254,9 +254,9 @@ to
## From v2 to v3
You can upgrade from v2 to v3 by performing these renames in your model that has media.

- `Spatie\MediaLibrary\HasMediaTrait` has been renamed to `Spatie\MediaLibrary\HasMedia\HasMediaTrait`.
- `Spatie\MediaLibrary\HasMedia` has been renamed to `Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions`
- `Spatie\MediaLibrary\HasMediaWithoutConversions` has been renamed to `Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia`
- `Programic\MediaLibrary\HasMediaTrait` has been renamed to `Programic\MediaLibrary\HasMedia\HasMediaTrait`.
- `Programic\MediaLibrary\HasMedia` has been renamed to `Programic\MediaLibrary\HasMedia\Interfaces\HasMediaConversions`
- `Programic\MediaLibrary\HasMediaWithoutConversions` has been renamed to `Programic\MediaLibrary\HasMedia\Interfaces\HasMedia`

In the config file you should rename the `filesystem`-option to `default_filesystem`.

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "spatie/laravel-medialibrary",
"name": "programic/laravel-medialibrary",
"description": "Associate files with Eloquent models",
"license": "MIT",
"keywords": [
Expand Down Expand Up @@ -67,12 +67,12 @@
"prefer-stable": true,
"autoload": {
"psr-4": {
"Spatie\\MediaLibrary\\": "src"
"Programic\\MediaLibrary\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Spatie\\MediaLibrary\\Tests\\": "tests"
"Programic\\MediaLibrary\\Tests\\": "tests"
}
},
"config": {
Expand All @@ -85,7 +85,7 @@
"extra": {
"laravel": {
"providers": [
"Spatie\\MediaLibrary\\MediaLibraryServiceProvider"
"Programic\\MediaLibrary\\MediaLibraryServiceProvider"
]
}
},
Expand Down
37 changes: 19 additions & 18 deletions config/media-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@
/*
* The fully qualified class name of the media model.
*/
'media_model' => Spatie\MediaLibrary\MediaCollections\Models\Media::class,
'media_model' => Programic\MediaLibrary\MediaCollections\Models\Media::class,
'mediable_model' => Programic\MediaLibrary\MediaCollections\Models\Mediable::class,

/*
* The fully qualified class name of the media observer.
*/
'media_observer' => Spatie\MediaLibrary\MediaCollections\Models\Observers\MediaObserver::class,
'media_observer' => Programic\MediaLibrary\MediaCollections\Models\Observers\MediaObserver::class,

/*
* When enabled, media collections will be serialised using the default
Expand All @@ -59,7 +60,7 @@
*
* This model is only used in Media Library Pro (https://medialibrary.pro)
*/
'temporary_upload_model' => Spatie\MediaLibraryPro\Models\TemporaryUpload::class,
'temporary_upload_model' => Programic\MediaLibraryPro\Models\TemporaryUpload::class,

/*
* When enabled, Media Library Pro will only process temporary uploads that were uploaded
Expand All @@ -76,17 +77,17 @@
/*
* This is the class that is responsible for naming generated files.
*/
'file_namer' => Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer::class,
'file_namer' => Programic\MediaLibrary\Support\FileNamer\DefaultFileNamer::class,

/*
* The class that contains the strategy for determining a media file's path.
*/
'path_generator' => Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator::class,
'path_generator' => Programic\MediaLibrary\Support\PathGenerator\DefaultPathGenerator::class,

/*
* The class that contains the strategy for determining how to remove files.
*/
'file_remover_class' => Spatie\MediaLibrary\Support\FileRemover\DefaultFileRemover::class,
'file_remover_class' => Programic\MediaLibrary\Support\FileRemover\DefaultFileRemover::class,

/*
* Here you can specify which path generator should be used for the given class.
Expand All @@ -101,7 +102,7 @@
* When urls to files get generated, this class will be called. Use the default
* if your files are stored locally above the site root or on s3.
*/
'url_generator' => Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class,
'url_generator' => Programic\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class,

/*
* Moves media on updating to keep path consistent. Enable it only with a custom
Expand Down Expand Up @@ -164,12 +165,12 @@
* These generators will be used to create an image of media files.
*/
'image_generators' => [
Spatie\MediaLibrary\Conversions\ImageGenerators\Image::class,
Spatie\MediaLibrary\Conversions\ImageGenerators\Webp::class,
Spatie\MediaLibrary\Conversions\ImageGenerators\Avif::class,
Spatie\MediaLibrary\Conversions\ImageGenerators\Pdf::class,
Spatie\MediaLibrary\Conversions\ImageGenerators\Svg::class,
Spatie\MediaLibrary\Conversions\ImageGenerators\Video::class,
Programic\MediaLibrary\Conversions\ImageGenerators\Image::class,
Programic\MediaLibrary\Conversions\ImageGenerators\Webp::class,
Programic\MediaLibrary\Conversions\ImageGenerators\Avif::class,
Programic\MediaLibrary\Conversions\ImageGenerators\Pdf::class,
Programic\MediaLibrary\Conversions\ImageGenerators\Svg::class,
Programic\MediaLibrary\Conversions\ImageGenerators\Video::class,
],

/*
Expand Down Expand Up @@ -197,16 +198,16 @@
* your custom jobs extend the ones provided by the package.
*/
'jobs' => [
'perform_conversions' => Spatie\MediaLibrary\Conversions\Jobs\PerformConversionsJob::class,
'generate_responsive_images' => Spatie\MediaLibrary\ResponsiveImages\Jobs\GenerateResponsiveImagesJob::class,
'perform_conversions' => Programic\MediaLibrary\Conversions\Jobs\PerformConversionsJob::class,
'generate_responsive_images' => Programic\MediaLibrary\ResponsiveImages\Jobs\GenerateResponsiveImagesJob::class,
],

/*
* When using the addMediaFromUrl method you may want to replace the default downloader.
* This is particularly useful when the url of the image is behind a firewall and
* need to add additional flags, possibly using curl.
*/
'media_downloader' => Spatie\MediaLibrary\Downloaders\DefaultDownloader::class,
'media_downloader' => Programic\MediaLibrary\Downloaders\DefaultDownloader::class,

/*
* When using the addMediaFromUrl method the SSL is verified by default.
Expand Down Expand Up @@ -237,7 +238,7 @@
*
* https://docs.spatie.be/laravel-medialibrary/v9/advanced-usage/generating-responsive-images
*/
'width_calculator' => Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator::class,
'width_calculator' => Programic\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator::class,

/*
* By default rendering media to a responsive image will add some javascript and a tiny placeholder.
Expand All @@ -250,7 +251,7 @@
* This class will generate the tiny placeholder used for progressive image loading. By default
* the media library will use a tiny blurred jpg image.
*/
'tiny_placeholder_generator' => Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class,
'tiny_placeholder_generator' => Programic\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class,
],

/*
Expand Down
Loading