init
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="fields" method="upgrade">
|
||||
<name>plg_fields_media</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2016-03</creationDate>
|
||||
<copyright>(C) 2016 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.7.0</version>
|
||||
<description>PLG_FIELDS_MEDIA_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\Fields\Media</namespace>
|
||||
<files>
|
||||
<folder>params</folder>
|
||||
<folder plugin="media">services</folder>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_media.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_fields_media.sys.ini</language>
|
||||
</languages>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="directory"
|
||||
type="media"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
|
||||
preview="false"
|
||||
types="directories"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="preview"
|
||||
type="list"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
|
||||
class="list"
|
||||
default="true"
|
||||
validate="options"
|
||||
>
|
||||
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
|
||||
<option value="false">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_IMAGE_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="directory"
|
||||
type="media"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
|
||||
preview="false"
|
||||
types="directories"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="preview"
|
||||
type="list"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
|
||||
<option value="false">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="css_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_CSS_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field name="spacer" type="spacer" hr="true"/>
|
||||
|
||||
<field
|
||||
type="hidden"
|
||||
name="types"
|
||||
default="audios"
|
||||
/>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="controls"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_CONTROLS_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="autoplay"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_AUTOPLAY_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="loop"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_LOOP_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="muted"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_MUTED_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
showon="autoplay:1"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="list"
|
||||
name="preload"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PRELOAD_LABEL"
|
||||
validate="options"
|
||||
default="auto"
|
||||
showon="autoplay:0"
|
||||
>
|
||||
<option value="auto">PLG_FIELDS_MEDIA_PARAMS_PRELOAD_AUTO</option>
|
||||
<option value="none">PLG_FIELDS_MEDIA_PARAMS_PRELOAD_NONE</option>
|
||||
<option value="metadata">PLG_FIELDS_MEDIA_PARAMS_PRELOAD_METADATA</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="directory"
|
||||
type="media"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
|
||||
preview="false"
|
||||
types="directories"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="preview"
|
||||
type="list"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
|
||||
<option value="false">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="css_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_CSS_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
type="hidden"
|
||||
name="types"
|
||||
default="documents"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="directory"
|
||||
type="media"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
|
||||
preview="false"
|
||||
types="directories"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="preview"
|
||||
type="list"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
|
||||
<option value="false">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="image_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_IMAGE_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
type="hidden"
|
||||
name="types"
|
||||
default="images"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field
|
||||
name="directory"
|
||||
type="media"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_DIRECTORY_LABEL"
|
||||
preview="false"
|
||||
types="directories"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="preview"
|
||||
type="list"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PREVIEW_LABEL"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
|
||||
<option value="true">PLG_FIELDS_MEDIA_PARAMS_PREVIEW_INLINE</option>
|
||||
<option value="false">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="css_class"
|
||||
type="textarea"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_CSS_CLASS_LABEL"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
<field name="spacer" type="spacer" hr="true" />
|
||||
|
||||
<field
|
||||
type="hidden"
|
||||
name="types"
|
||||
default="videos"
|
||||
/>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="video_poster"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_VIDEO_POSTER_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="controls"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_CONTROLS_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="autoplay"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_AUTOPLAY_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="muted"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_MUTED_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
showon="autoplay:1"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="loop"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_LOOP_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="radio"
|
||||
name="video_playsinline"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_VIDEO_PLAYSINLINE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="1"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
type="list"
|
||||
name="preload"
|
||||
label="PLG_FIELDS_MEDIA_PARAMS_PRELOAD_LABEL"
|
||||
validate="options"
|
||||
default="auto"
|
||||
showon="autoplay:0"
|
||||
>
|
||||
<option value="auto">PLG_FIELDS_MEDIA_PARAMS_PRELOAD_AUTO</option>
|
||||
<option value="none">PLG_FIELDS_MEDIA_PARAMS_PRELOAD_NONE</option>
|
||||
<option value="metadata">PLG_FIELDS_MEDIA_PARAMS_PRELOAD_METADATA</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.media
|
||||
*
|
||||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Plugin\Fields\Media\Extension\Media;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
$container->lazy(Media::class, function (Container $container) {
|
||||
$plugin = new Media(
|
||||
(array) PluginHelper::getPlugin('fields', 'media')
|
||||
);
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.media
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\Fields\Media\Extension;
|
||||
|
||||
use Joomla\CMS\Event\CustomFields\BeforePrepareFieldEvent;
|
||||
use Joomla\CMS\Event\Model\PrepareDataEvent;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Fields Media Plugin
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
final class Media extends FieldsPlugin implements SubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Returns an array of events this subscriber will listen to.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return array_merge(parent::getSubscribedEvents(), [
|
||||
'onContentPrepareData' => 'prepareContentData',
|
||||
'onCustomFieldsBeforePrepareField' => 'beforePrepareField',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the fieldparams[types] parameter because the default value from the
|
||||
* XML form get not overridden on field reload
|
||||
*
|
||||
* @param PrepareDataEvent $event The event instance.
|
||||
*
|
||||
* @return void
|
||||
* @since 6.1.0
|
||||
*/
|
||||
public function prepareContentData(PrepareDataEvent $event)
|
||||
{
|
||||
$context = $event->getContext();
|
||||
$data = $event->getData();
|
||||
|
||||
if ($context !== 'com_fields.field') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($data->type) && $data->type !== 'media') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (\is_array($data)) {
|
||||
unset($data['fieldparams']['types']);
|
||||
} elseif (\is_object($data)) {
|
||||
unset($data->fieldparams['types']);
|
||||
}
|
||||
|
||||
$event->updateData($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field into a DOM XML element and appends it as a child on the given parent.
|
||||
*
|
||||
* @param \stdClass $field The field.
|
||||
* @param \DOMElement $parent The field node parent.
|
||||
* @param Form $form The form.
|
||||
*
|
||||
* @return ?\DOMElement
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function onCustomFieldsPrepareDom($field, \DOMElement $parent, Form $form)
|
||||
{
|
||||
$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form);
|
||||
|
||||
if (!$fieldNode) {
|
||||
return $fieldNode;
|
||||
}
|
||||
|
||||
$fieldNode->setAttribute('type', 'accessiblemedia');
|
||||
|
||||
if ($this->getApplication()->getIdentity()->authorise('core.create', 'com_media')) {
|
||||
$fieldNode->setAttribute('disabled', 'false');
|
||||
}
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Before prepares the field value.
|
||||
*
|
||||
* @param BeforePrepareFieldEvent $event The event instance.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function beforePrepareField(BeforePrepareFieldEvent $event): void
|
||||
{
|
||||
$field = $event->getField();
|
||||
|
||||
// Check if the field should be processed by us
|
||||
if (!$this->isTypeSupported($field->type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the field value is an old (string) value
|
||||
$field->value = $this->checkValue($field->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Before prepares the field value.
|
||||
*
|
||||
* @param string $value The value to check.
|
||||
*
|
||||
* @return array The checked value
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
private function checkValue($value)
|
||||
{
|
||||
json_decode($value);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
return (array) json_decode($value, true);
|
||||
}
|
||||
|
||||
return ['imagefile' => $value, 'alt_text' => ''];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Media
|
||||
*
|
||||
* @copyright (C) 2026 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
if (empty($field->value) || empty($field->value['file'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$displayData = [
|
||||
'src' => $field->value['file'],
|
||||
];
|
||||
|
||||
if ($class = (string) $fieldParams->get('css_class', '')) {
|
||||
$displayData['class'] = $class;
|
||||
}
|
||||
|
||||
if ($fieldParams->get('controls', 1) === 1) {
|
||||
$displayData['controls'] = 'controls';
|
||||
}
|
||||
|
||||
if ($fieldParams->get('autoplay', 0) === 1) {
|
||||
$displayData['autoplay'] = 'autoplay';
|
||||
}
|
||||
|
||||
if ($fieldParams->get('loop', 0) === 1) {
|
||||
$displayData['loop'] = 'loop';
|
||||
}
|
||||
|
||||
if ($fieldParams->get('muted', 0) === 1) {
|
||||
$displayData['muted'] = 'muted';
|
||||
}
|
||||
|
||||
$displayData['preload'] = $fieldParams->get('preload', 'auto');
|
||||
|
||||
echo LayoutHelper::render('joomla.html.audio', $displayData);
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Media
|
||||
*
|
||||
* @copyright (C) 2026 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Helper\MediaHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Uri\Uri;
|
||||
|
||||
if (empty($file = $field->value) || empty($field->value['file'])) {
|
||||
return;
|
||||
}
|
||||
$fileUrl = MediaHelper::getCleanMediaFieldValue($field->value['file']);
|
||||
// detect local file path
|
||||
$isLocalFile = false;
|
||||
if (empty((new Uri($fileUrl))->getHost())) {
|
||||
$fileUrl = JPATH_SITE . DIRECTORY_SEPARATOR . $fileUrl;
|
||||
$isLocalFile = true;
|
||||
}
|
||||
if ($isLocalFile && !\is_file($fileUrl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = $fieldParams->get('css_class');
|
||||
$options = [];
|
||||
|
||||
if ($class) {
|
||||
$options['class'] = $class;
|
||||
}
|
||||
$linkText = $field->value['linktext'] ?? Text::_('JLIB_FORM_FIELD_PARAM_ACCESSIBLEMEDIA_PARAMS_LINKTEXT_DEFAULT_VALUE');
|
||||
$fileUrl = $isLocalFile ? $field->value['file'] : $fileUrl;
|
||||
if (str_contains($linkText, '{filename}')) {
|
||||
$linkText = str_replace('{filename}', basename($fileUrl), $linkText);
|
||||
}
|
||||
echo HTMLHelper::link($fileUrl, $linkText, $options);
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Media
|
||||
*
|
||||
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
if (empty($field->value) || empty($field->value['imagefile'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = $fieldParams->get('image_class');
|
||||
$options = [
|
||||
'src' => $field->value['imagefile'],
|
||||
'alt' => empty($field->value['alt_text']) && empty($field->value['alt_empty']) ? false : $field->value['alt_text'],
|
||||
];
|
||||
|
||||
if ($class) {
|
||||
$options['class'] = $class;
|
||||
}
|
||||
|
||||
echo LayoutHelper::render('joomla.html.image', $options);
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage Fields.Media
|
||||
*
|
||||
* @copyright (C) 2026 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
if (empty($field->value) || empty($field->value['file'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$displayData = [
|
||||
'src' => $field->value['file'],
|
||||
];
|
||||
|
||||
|
||||
if (!empty($class = (string) $fieldParams->get('css_class', ''))) {
|
||||
$displayData['class'] = $class;
|
||||
}
|
||||
|
||||
if ((int) $fieldParams->get('video_poster', 1) && !empty($poster = $field->value['poster'])) {
|
||||
$displayData['poster'] = (HTMLHelper::cleanImageURL($poster))->url;
|
||||
}
|
||||
|
||||
if ($fieldParams->get('controls', 1)) {
|
||||
$displayData['controls'] = 'controls';
|
||||
}
|
||||
|
||||
if ($fieldParams->get('autoplay', 0)) {
|
||||
$displayData['autoplay'] = 'autoplay';
|
||||
}
|
||||
|
||||
if ($fieldParams->get('loop', 0)) {
|
||||
$displayData['loop'] = 'loop';
|
||||
}
|
||||
|
||||
if ($fieldParams->get('muted', 0)) {
|
||||
$displayData['muted'] = 'muted';
|
||||
}
|
||||
|
||||
if ($fieldParams->get('video_playsinline', 1)) {
|
||||
$displayData['playsinline'] = 'playsinline';
|
||||
}
|
||||
|
||||
$displayData['preload'] = $fieldParams->get('preload', 'auto');
|
||||
|
||||
echo LayoutHelper::render('joomla.html.video', $displayData);
|
||||
Reference in New Issue
Block a user