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
38871e2b
Unverified
Commit
38871e2b
authored
Jul 06, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creating a @thumbnail blade directive
parent
99e10caa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
1 deletion
+66
-1
MediaThumbnailDirective.php
Modules/Media/Blade/Facades/MediaThumbnailDirective.php
+13
-0
MediaThumbnailDirective.php
Modules/Media/Blade/MediaThumbnailDirective.php
+44
-0
MediaServiceProvider.php
Modules/Media/Providers/MediaServiceProvider.php
+7
-0
module.json
Modules/Media/module.json
+2
-1
No files found.
Modules/Media/Blade/Facades/MediaThumbnailDirective.php
0 → 100644
View file @
38871e2b
<?php
namespace
Modules\Media\Blade\Facades
;
use
Illuminate\Support\Facades\Facade
;
class
MediaThumbnailDirective
extends
Facade
{
protected
static
function
getFacadeAccessor
()
{
return
'media.thumbnail.directive'
;
}
}
Modules/Media/Blade/MediaThumbnailDirective.php
0 → 100644
View file @
38871e2b
<?php
namespace
Modules\Media\Blade
;
use
Modules\Media\Image\Imagy
;
class
MediaThumbnailDirective
{
/**
* @var string
*/
private
$path
;
/**
* @var string
*/
private
$thumbnail
;
/**
* @var Imagy
*/
private
$imagy
;
public
function
__construct
()
{
$this
->
imagy
=
app
(
Imagy
::
class
);
}
public
function
show
(
$arguments
)
{
$this
->
extractArguments
(
$arguments
);
return
$this
->
imagy
->
getThumbnail
(
$this
->
path
,
$this
->
thumbnail
);
}
/**
* Extract the possible arguments as class properties
* @param array $arguments
*/
private
function
extractArguments
(
array
$arguments
)
{
$this
->
path
=
array_get
(
$arguments
,
0
);
$this
->
thumbnail
=
array_get
(
$arguments
,
1
);
}
}
Modules/Media/Providers/MediaServiceProvider.php
View file @
38871e2b
...
@@ -8,6 +8,7 @@ use Illuminate\Support\ServiceProvider;
...
@@ -8,6 +8,7 @@ use Illuminate\Support\ServiceProvider;
use
Modules\Core\Traits\CanPublishConfiguration
;
use
Modules\Core\Traits\CanPublishConfiguration
;
use
Modules\Media\Blade\MediaMultipleDirective
;
use
Modules\Media\Blade\MediaMultipleDirective
;
use
Modules\Media\Blade\MediaSingleDirective
;
use
Modules\Media\Blade\MediaSingleDirective
;
use
Modules\Media\Blade\MediaThumbnailDirective
;
use
Modules\Media\Console\RefreshThumbnailCommand
;
use
Modules\Media\Console\RefreshThumbnailCommand
;
use
Modules\Media\Contracts\DeletingMedia
;
use
Modules\Media\Contracts\DeletingMedia
;
use
Modules\Media\Contracts\StoringMedia
;
use
Modules\Media\Contracts\StoringMedia
;
...
@@ -46,6 +47,9 @@ class MediaServiceProvider extends ServiceProvider
...
@@ -46,6 +47,9 @@ class MediaServiceProvider extends ServiceProvider
$this
->
app
->
bind
(
'media.multiple.directive'
,
function
()
{
$this
->
app
->
bind
(
'media.multiple.directive'
,
function
()
{
return
new
MediaMultipleDirective
();
return
new
MediaMultipleDirective
();
});
});
$this
->
app
->
bind
(
'media.thumbnail.directive'
,
function
()
{
return
new
MediaThumbnailDirective
();
});
}
}
public
function
boot
(
DispatcherContract
$events
)
public
function
boot
(
DispatcherContract
$events
)
...
@@ -143,5 +147,8 @@ class MediaServiceProvider extends ServiceProvider
...
@@ -143,5 +147,8 @@ class MediaServiceProvider extends ServiceProvider
$this
->
app
[
'blade.compiler'
]
->
directive
(
'mediaMultiple'
,
function
(
$value
)
{
$this
->
app
[
'blade.compiler'
]
->
directive
(
'mediaMultiple'
,
function
(
$value
)
{
return
"<?php echo MediaMultipleDirective::show([
$value
]); ?>"
;
return
"<?php echo MediaMultipleDirective::show([
$value
]); ?>"
;
});
});
$this
->
app
[
'blade.compiler'
]
->
directive
(
'thumbnail'
,
function
(
$value
)
{
return
"<?php echo MediaThumbnailDirective::show([
$value
]); ?>"
;
});
}
}
}
}
Modules/Media/module.json
View file @
38871e2b
...
@@ -17,7 +17,8 @@
...
@@ -17,7 +17,8 @@
"Imagy"
:
"Modules
\\
Media
\\
Image
\\
Facade
\\
Imagy"
,
"Imagy"
:
"Modules
\\
Media
\\
Image
\\
Facade
\\
Imagy"
,
"FileHelper"
:
"Modules
\\
Media
\\
Helpers
\\
FileHelper"
,
"FileHelper"
:
"Modules
\\
Media
\\
Helpers
\\
FileHelper"
,
"MediaSingleDirective"
:
"Modules
\\
Media
\\
Blade
\\
Facades
\\
MediaSingleDirective"
,
"MediaSingleDirective"
:
"Modules
\\
Media
\\
Blade
\\
Facades
\\
MediaSingleDirective"
,
"MediaMultipleDirective"
:
"Modules
\\
Media
\\
Blade
\\
Facades
\\
MediaMultipleDirective"
"MediaMultipleDirective"
:
"Modules
\\
Media
\\
Blade
\\
Facades
\\
MediaMultipleDirective"
,
"MediaThumbnailDirective"
:
"Modules
\\
Media
\\
Blade
\\
Facades
\\
MediaThumbnailDirective"
},
},
"files"
:
[
"files"
:
[
]
]
...
...
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