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

support for laravel 9 #55

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/coverage
/docs
/js
/.idea
node_modules
composer.phar
composer.lock
Expand Down
18 changes: 4 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "folklore/image",
"description": "Image manipulation library for Laravel 5 based on Imagine and inspired by Croppa for easy url based manipulation",
"name": "ayk/laravel-image-manipulation",
"description": "Image manipulation library for Laravel 9 based on Imagine and inspired by Croppa for easy url based manipulation",
"keywords": ["laravel","image","imagick","gd","imagine","watermark","gmagick","thumbnail"],
"homepage": "http://github.com/Folkloreatelier/laravel-image",
"license": "MIT",
Expand All @@ -19,8 +19,8 @@
],
"require": {
"php": ">=5.5.9",
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*",
"guzzlehttp/guzzle": "5.3|~6.0",
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0",
"guzzlehttp/guzzle": "5.3|~6.0|^7.0.1",
"imagine/imagine": "0.6.*"
},
"require-dev": {
Expand All @@ -40,15 +40,5 @@
"classmap": [
"tests/"
]
},
"extra": {
"laravel": {
"providers": [
"Folklore\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Folklore\\Image\\Facades\\Image"
}
}
}
}
50 changes: 25 additions & 25 deletions src/Folklore/Image/ImageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public function url($src, $width = null, $height = null, $options = array())
$width = null;
$height = null;
}
$config = $this->app['config'];

$config = app()['config'];
$url_parameter = isset($options['url_parameter']) ? $options['url_parameter']:$config['image.url_parameter'];
$url_parameter_separator = isset($options['url_parameter_separator']) ? $options['url_parameter_separator']:$config['image.url_parameter_separator'];
unset($options['url_parameter'],$options['url_parameter_separator']);
Expand Down Expand Up @@ -109,13 +109,13 @@ public function url($src, $width = null, $height = null, $options = array())

// Break the path apart and put back together again
$parts = pathinfo($src);
$host = isset($options['host']) ? $options['host']:$this->app['config']['image.host'];
$host = isset($options['host']) ? $options['host']:app()['config']['image.host'];
$dir = trim($parts['dirname'], '/');

$path = array();
$path[] = rtrim($host, '/');

if ($prefix = $this->app['config']->get('image.write_path')) {
if ($prefix = app()['config']->get('image.write_path')) {
$path[] = trim($prefix, '/');
}

Expand Down Expand Up @@ -144,7 +144,7 @@ public function url($src, $width = null, $height = null, $options = array())
public function make($path, $options = array())
{
//Get app config
$config = $this->app['config'];
$config = app()['config'];

// See if the referenced file exists and is an image
if (!($path = $this->getRealPath($path))) {
Expand Down Expand Up @@ -226,16 +226,16 @@ public function make($path, $options = array())
public function serve($path, $config = array())
{
//Use user supplied quality or the config value
$quality = array_get($config, 'quality', $this->app['config']['image.quality']);
$quality = array_get($config, 'quality', app()['config']['image.quality']);
//if nothing works fallback to the hardcoded value
$quality = $quality ?: $this->defaultOptions['quality'];

//Merge config with defaults
$config = array_merge(array(
'quality' => $quality,
'custom_filters_only' => $this->app['config']['image.serve_custom_filters_only'],
'write_image' => $this->app['config']['image.write_image'],
'write_path' => $this->app['config']['image.write_path']
'custom_filters_only' => app()['config']['image.serve_custom_filters_only'],
'write_image' => app()['config']['image.write_image'],
'write_path' => app()['config']['image.write_path']
), $config);

$serve = new ImageServe($this, $config);
Expand All @@ -254,12 +254,12 @@ public function proxy($path, $config = array())
{
//Merge config with defaults
$config = array_merge(array(
'tmp_path' => $this->app['config']['image.proxy_tmp_path'],
'filesystem' => $this->app['config']['image.proxy_filesystem'],
'cache' => $this->app['config']['image.proxy_cache'],
'cache_expiration' => $this->app['config']['image.proxy_cache_expiration'],
'write_image' => $this->app['config']['image.proxy_write_image'],
'cache_filesystem' => $this->app['config']['image.proxy_cache_filesystem']
'tmp_path' => app()['config']['image.proxy_tmp_path'],
'filesystem' => app()['config']['image.proxy_filesystem'],
'cache' => app()['config']['image.proxy_cache'],
'cache_expiration' => app()['config']['image.proxy_cache_expiration'],
'write_image' => app()['config']['image.proxy_write_image'],
'cache_filesystem' => app()['config']['image.proxy_cache_filesystem']
), $config);

$serve = new ImageProxy($this, $config);
Expand Down Expand Up @@ -420,7 +420,7 @@ public function deleteManipulated($path)
public function pattern($parameter = null, $pattern = null)
{
//Replace the {options} with the options regular expression
$config = $this->app['config'];
$config = app()['config'];
$parameter = !isset($parameter) ? $config['image.url_parameter']:$parameter;
$parameter = preg_replace('/\\\{\s*options\s*\\\}/', '([0-9a-zA-Z\(\),\-/._]+?)?', preg_quote($parameter));

Expand All @@ -446,7 +446,7 @@ public function parse($path, $config = array())
$config = array_merge(array(
'custom_filters_only' => false,
'url_parameter' => null,
'url_parameter_separator' => $this->app['config']['image.url_parameter_separator']
'url_parameter_separator' => app()['config']['image.url_parameter_separator']
), $config);

$parsedOptions = array();
Expand Down Expand Up @@ -478,7 +478,7 @@ protected function parseOptions($option_path, $config = array())
//Default config
$config = array_merge(array(
'custom_filters_only' => false,
'url_parameter_separator' => $this->app['config']['image.url_parameter_separator']
'url_parameter_separator' => app()['config']['image.url_parameter_separator']
), $config);

$options = array();
Expand Down Expand Up @@ -562,9 +562,9 @@ public function getRealPath($path)
}

//Get directories
$dirs = $this->app['config']['image.src_dirs'];
if ($this->app['config']['image.write_path']) {
$dirs[] = $this->app['config']['image.write_path'];
$dirs = app()['config']['image.src_dirs'];
if (app()['config']['image.write_path']) {
$dirs[] = app()['config']['image.write_path'];
}

// Loop through all the directories files may be uploaded to
Expand Down Expand Up @@ -614,8 +614,8 @@ protected function getFiles($path, $withOriginal = true)
$parts = pathinfo($path);
$dirs = [$parts['dirname']];
$dirs = [$parts['dirname']];
if ($this->app['config']['image.write_path']) {
$dirs[] = $this->app['config']['image.write_path'];
if (app()['config']['image.write_path']) {
$dirs[] = app()['config']['image.write_path'];
}
foreach ($dirs as $directory) {
$files = scandir($directory);
Expand Down Expand Up @@ -837,7 +837,7 @@ protected function createGmagickDriver()
*/
public function getDefaultDriver()
{
return $this->app['config']['image.driver'];
return app()['config']['image.driver'];
}

/**
Expand All @@ -848,6 +848,6 @@ public function getDefaultDriver()
*/
public function setDefaultDriver($name)
{
$this->app['config']['image.driver'] = $name;
app()['config']['image.driver'] = $name;
}
}