Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
fbe604cb
Commit
fbe604cb
authored
Oct 31, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the destination as configuration
parent
98b6cbe8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
7 deletions
+14
-7
config.php
Config/config.php
+1
-1
ImageServiceProvider.php
Image/ImageServiceProvider.php
+1
-1
Imagy.php
Image/Imagy.php
+11
-4
ImagyTest.php
Tests/ImagyTest.php
+1
-1
No files found.
Config/config.php
View file @
fbe604cb
...
...
@@ -6,7 +6,7 @@ return [
| The path where the media files will be uploaded
|--------------------------------------------------------------------------
*/
'file
-path'
=>
'/assets/media
'
,
'file
s-path'
=>
'/assets/media/
'
,
/*
|--------------------------------------------------------------------------
| Specify all the allowed file extensions a user can upload on the server
...
...
Image/ImageServiceProvider.php
View file @
fbe604cb
...
...
@@ -27,7 +27,7 @@ class ImageServiceProvider extends ServiceProvider
$factory
=
new
InterventionFactory
;
$thumbnailManager
=
new
ThumbnailsManager
(
$app
[
'config'
],
$app
[
'modules'
]);
return
new
Imagy
(
$factory
,
$thumbnailManager
);
return
new
Imagy
(
$factory
,
$thumbnailManager
,
$app
[
'config'
]
);
});
$this
->
app
->
booting
(
function
()
...
...
Image/Imagy.php
View file @
fbe604cb
<?php
namespace
Modules\Media\Image
;
use
Illuminate\Contracts\Config\Repository
;
use
Illuminate\Support\Facades\App
;
class
Imagy
...
...
@@ -26,17 +27,23 @@ class Imagy
* @var array
*/
private
$imageExtensions
=
[
'jpg'
,
'png'
,
'jpeg'
,
'gif'
];
/**
* @var Repository
*/
private
$config
;
/**
* @param ImageFactoryInterface $imageFactory
* @param ThumbnailsManager $manager
* @param Repository $config
*/
public
function
__construct
(
ImageFactoryInterface
$imageFactory
,
ThumbnailsManager
$manager
)
public
function
__construct
(
ImageFactoryInterface
$imageFactory
,
ThumbnailsManager
$manager
,
Repository
$config
)
{
$this
->
image
=
App
::
make
(
'Intervention\Image\ImageManager'
);
$this
->
finder
=
App
::
make
(
'Illuminate\Filesystem\Filesystem'
);
$this
->
imageFactory
=
$imageFactory
;
$this
->
manager
=
$manager
;
$this
->
config
=
$config
;
}
/**
...
...
@@ -50,7 +57,7 @@ class Imagy
{
if
(
!
$this
->
isImage
(
$path
))
return
;
$filename
=
'/assets/media/'
.
$this
->
newFilename
(
$path
,
$thumbnail
);
$filename
=
$this
->
config
->
get
(
'media::config.files-path'
)
.
$this
->
newFilename
(
$path
,
$thumbnail
);
if
(
$this
->
returnCreatedFile
(
$filename
,
$forceCreate
))
{
return
$filename
;
...
...
@@ -71,7 +78,7 @@ class Imagy
{
if
(
!
$this
->
isImage
(
$originalImage
))
return
$originalImage
;
return
'/assets/media/'
.
$this
->
newFilename
(
$originalImage
,
$thumbnail
);
return
$this
->
config
->
get
(
'media::config.files-path'
)
.
$this
->
newFilename
(
$originalImage
,
$thumbnail
);
}
/**
...
...
@@ -84,7 +91,7 @@ class Imagy
foreach
(
$this
->
manager
->
all
()
as
$thumbName
=>
$filters
)
{
$image
=
$this
->
image
->
make
(
public_path
()
.
$path
);
$filename
=
'/assets/media/'
.
$this
->
newFilename
(
$path
,
$thumbName
);
$filename
=
$this
->
config
->
get
(
'media::config.files-path'
)
.
$this
->
newFilename
(
$path
,
$thumbName
);
foreach
(
$filters
as
$manipulation
=>
$options
)
{
$image
=
$this
->
imageFactory
->
make
(
$manipulation
)
->
handle
(
$image
,
$options
);
}
...
...
Tests/ImagyTest.php
View file @
fbe604cb
...
...
@@ -23,7 +23,7 @@ class ImagyTest extends BaseTestCase
$config
=
App
::
make
(
'Illuminate\Contracts\Config\Repository'
);
$module
=
App
::
make
(
'Pingpong\Modules\Module'
);
$this
->
finder
=
App
::
make
(
'Illuminate\Filesystem\Filesystem'
);
$this
->
imagy
=
new
Imagy
(
new
InterventionFactory
,
new
ThumbnailsManager
(
$config
,
$module
));
$this
->
imagy
=
new
Imagy
(
new
InterventionFactory
,
new
ThumbnailsManager
(
$config
,
$module
)
,
$config
);
}
/** @test */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment