Skip to content

Commit

Permalink
Merge pull request #89 from netgen/admin-issues-fixes
Browse files Browse the repository at this point in the history
Various improvements in admin
  • Loading branch information
iherak authored Dec 2, 2021
2 parents 96ef088 + 94dddc2 commit 45be98e
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bundle/RemoteMedia/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function formatBrowseItem(Value $value)

if ($mediaType === Value::TYPE_IMAGE) {
$browseUrl = $this->provider->buildVariation($value, 'admin', $thumbOptions)->url;
$previewUrl = $value->secure_url;
$previewUrl = $this->provider->buildVariation($value, 'default', 'admin_preview')->url;
} elseif ($mediaType === Value::TYPE_VIDEO) {
$browseUrl = $this->provider->getVideoThumbnail($value, $thumbOptions);
$previewUrl = $this->provider->getVideoThumbnail($value);
$previewUrl = $this->provider->getVideoThumbnail($value, ['content_type_identifier' => 'default', 'variation_name' => 'admin_preview']);
} else {
$browseUrl = '';
$previewUrl = '';
Expand Down
6 changes: 6 additions & 0 deletions bundle/RemoteMedia/Provider/Cloudinary/CloudinaryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ public function updateResourceContext(string $resourceId, string $resourceType,
*/
public function getVideoThumbnail(Value $value, $options = []): string
{
if (array_key_exists('content_type_identifier', $options) && array_key_exists('variation_name', $options)) {
$options['transformation'] = $this->processConfiguredVariation($value, $options['variation_name'], $options['content_type_identifier']);
unset($options['content_type_identifier']);
unset($options['variation_name']);
}

if (count($options) === 0 || !array_key_exists('resource_type', $options)) {
$options['resource_type'] = 'video';
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/Resources/config/default_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ system:
default:
admin_preview:
transformations:
- { name: limit, params: [600,600] }
- { name: limit, params: [400,400] }
ng_article:
test:
transformations:
Expand Down
2 changes: 1 addition & 1 deletion bundle/Resources/public/css/remotemedia.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/Resources/public/js/remotemedia.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
type: "{% if field_value %}{{ field_value.resourceType|default('image') }}{% else %}image{% endif %}",
{% if not field_value or field_value.mediaType == 'image' %}
mediaType: "image",
previewUrl: "{% if field_value %}{{ field_value.secure_url }}{% endif %}",
previewUrl: "{% if field_value %}{{ netgen_remote_media(field_value, 'admin_preview').url }}{% endif %}",
{% elseif field_value.mediaType == 'video' %}
mediaType: "video",
previewUrl: "{{ netgen_remote_video_thumbnail(field_value) }}",
previewUrl: "{{ netgen_remote_video_thumbnail(field_value, {'content_type_identifier': 'default', 'variation_name': 'admin_preview'}) }}",
{% else %}
mediaType: "other",
previewUrl: "",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
}

{if $value.resourceId}
{def $format = 'admin_preview'}
{if $value.mediaType|eq('image')}
{def $format = 'admin_preview'}
{def $variation = ngremotemedia($value, $attribute.object.class_identifier, $format)}

{if not(is_set($alt_text))}
Expand All @@ -29,7 +29,7 @@

<br/>

{def $thumbnail = videoThumbnail($value)}
{def $thumbnail = videoThumbnail($value, hash('content_type_identifier', $attribute.object.class_identifier, 'variation_name', $format))}
<img src="{$thumbnail}"/>
{else}
<i class="fa fa-book" aria-hidden="true"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ function namedParameterList()
'value' => array(
'type' => 'Value',
'required' => true
),
'options' => array(
'type' => 'array',
'required' => false
)
),
'ngremotevideo' => array(
Expand Down Expand Up @@ -146,7 +150,7 @@ function modify(
} elseif ($operatorName === 'ng_remote_croppable') {
$operatorValue = $this->isCroppable($namedParameters['class_identifier']);
} elseif ($operatorName === 'videoThumbnail') {
$operatorValue = $this->videoThumbnail($namedParameters['value']);
$operatorValue = $this->videoThumbnail($namedParameters['value'], $namedParameters['options']);
} elseif ($operatorName === 'ngremotevideo') {
$operatorValue = $this->getvideoTag(
$namedParameters['value'],
Expand Down Expand Up @@ -228,12 +232,12 @@ function isCroppable($class_identifier)
return !empty($variationResolver->getCroppbableVariations($class_identifier));
}

function videoThumbnail($value)
function videoThumbnail($value, $options = [])
{
$container = ezpKernel::instance()->getServiceContainer();
$provider = $container->get( 'netgen_remote_media.provider' );

return $provider->getVideoThumbnail($value);
return $provider->getVideoThumbnail($value, $options);
}

function getVideoTag($value, $availableFormats, $format)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
left: 0;
right: 0;
background-color: rgba(0, 0, 0, .8);
z-index: 11;
z-index: 500000;

.media-modal {
background-color: $wild-sand;
Expand Down

0 comments on commit 45be98e

Please sign in to comment.