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
e0b8c32f
Commit
e0b8c32f
authored
Oct 30, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a thumbnailManager
parent
e8838c90
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
12 deletions
+53
-12
ImageServiceProvider.php
Image/ImageServiceProvider.php
+1
-1
Imagy.php
Image/Imagy.php
+13
-11
ThumbnailsManager.php
Image/ThumbnailsManager.php
+37
-0
FileService.php
Services/FileService.php
+2
-0
No files found.
Image/ImageServiceProvider.php
View file @
e0b8c32f
...
...
@@ -24,7 +24,7 @@ class ImageServiceProvider extends ServiceProvider
);
$this
->
app
[
'imagy'
]
=
$this
->
app
->
share
(
function
(
$app
)
{
return
new
Imagy
(
$app
[
'config'
],
new
InterventionFactory
);
return
new
Imagy
(
new
InterventionFactory
,
new
ThumbnailsManager
(
$app
[
'config'
],
$app
[
'modules'
])
);
});
$this
->
app
->
booting
(
function
()
...
...
Image/Imagy.php
View file @
e0b8c32f
<?php
namespace
Modules\Media\Image
;
use
Illuminate\Support\Facades\App
;
use
Illuminate\Contracts\Config\Repository
;
class
Imagy
{
...
...
@@ -13,21 +12,21 @@ class Imagy
* @var \Illuminate\Filesystem\Filesystem
*/
private
$finder
;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
private
$config
;
/**
* @var ImageFactoryInterface
*/
private
$imageFactory
;
/**
* @var ThumbnailsManager
*/
private
$manager
;
public
function
__construct
(
Repository
$config
,
ImageFactoryInterface
$imageFactory
)
public
function
__construct
(
ImageFactoryInterface
$imageFactory
,
ThumbnailsManager
$manager
)
{
$this
->
image
=
App
::
make
(
'Intervention\Image\ImageManager'
);
$this
->
finder
=
App
::
make
(
'Illuminate\Filesystem\Filesystem'
);
$this
->
config
=
$config
;
$this
->
imageFactory
=
$imageFactory
;
$this
->
manager
=
$manager
;
}
/**
...
...
@@ -45,7 +44,7 @@ class Imagy
return
$filename
;
}
$this
->
makeNew
(
$path
,
$
thumbnail
,
$filename
);
$this
->
makeNew
(
$path
,
$
filename
,
$thumbnail
);
return
$filename
;
}
...
...
@@ -98,14 +97,16 @@ class Imagy
/**
* Make a new image
* @param string $path
* @param string $thumbnail
* @param string $filename
* @param string null $thumbnail
*/
private
function
makeNew
(
$path
,
$
thumbnail
,
$filename
)
private
function
makeNew
(
$path
,
$
filename
,
$thumbnail
=
null
)
{
$image
=
$this
->
image
->
make
(
public_path
()
.
$path
);
foreach
(
$this
->
config
->
get
(
"media::thumbnails.
{
$thumbnail
}
"
)
as
$manipulation
=>
$options
)
{
$thumbnails
=
$thumbnail
?:
$this
->
manager
->
all
();
foreach
(
$thumbnails
as
$manipulation
=>
$options
)
{
$image
=
$this
->
imageFactory
->
make
(
$manipulation
)
->
handle
(
$image
,
$options
);
}
...
...
@@ -113,4 +114,5 @@ class Imagy
$this
->
writeImage
(
$filename
,
$image
);
}
}
Image/ThumbnailsManager.php
0 → 100644
View file @
e0b8c32f
<?php
namespace
Modules\Media\Image
;
use
Illuminate\Contracts\Config\Repository
;
use
Pingpong\Modules\Module
;
class
ThumbnailsManager
{
/**
* @var Module
*/
private
$module
;
/**
* @var Repository
*/
private
$config
;
/**
* @param Repository $config
* @param Module $module
*/
public
function
__construct
(
Repository
$config
,
Module
$module
)
{
$this
->
module
=
$module
;
$this
->
config
=
$config
;
}
public
function
all
()
{
$thumbnails
=
[];
foreach
(
$this
->
module
->
enabled
()
as
$enabledModule
)
{
$configuration
=
$this
->
config
->
get
(
strtolower
(
$enabledModule
)
.
'::thumbnails'
);
$thumbnails
=
array_merge
(
$thumbnails
,
$configuration
);
}
return
$thumbnails
;
}
}
Services/FileService.php
View file @
e0b8c32f
...
...
@@ -23,6 +23,8 @@ class FileService
// Move the uploaded file to /public/assets/media/
$file
->
move
(
public_path
()
.
'/assets/media'
,
$savedFile
->
filename
);
// Create the thumbnails
return
$savedFile
;
}
...
...
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