Skip to content

Commit

Permalink
Media select directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed May 30, 2024
1 parent 56cc278 commit bea594e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class JoomlaFieldMedia extends HTMLElement {
}

static get observedAttributes() {
return ['type', 'base-path', 'root-folder', 'url', 'modal-title', 'modal-width', 'modal-height', 'input', 'button-select', 'button-clear', 'preview', 'preview-width', 'preview-height'];
return ['base-path', 'root-folder', 'url', 'modal-title', 'modal-width', 'modal-height', 'input', 'button-select', 'button-clear', 'preview', 'preview-width', 'preview-height'];
}

get type() { return this.getAttribute('type'); }
get types() { return this.getAttribute('types') || ''; }

set type(value) { this.setAttribute('type', value); }
set types(value) { this.setAttribute('types', value); }

get basePath() { return this.getAttribute('base-path'); }

Expand Down Expand Up @@ -176,7 +176,7 @@ class JoomlaFieldMedia extends HTMLElement {
async modalClose() {
try {
const item = Joomla.selectedMediaFile;
if (item && item.type === 'dir') {
if (item && item.type === 'dir' && this.types.includes('directories')) {
this.setValue(item.path);
} else {
await Joomla.getMedia(Joomla.selectedMediaFile, this.inputElement, this);
Expand Down
4 changes: 3 additions & 1 deletion layouts/joomla/form/field/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
* @var integer $size The size text
* @var string $value The value text
* @var string $src The path and filename of the image
* @var array $mediaTypes The supported media types for the Media Manager
* @var string $mediaTypes The ids of supported media types for the Media Manager
* @var array $mediaTypeNames The names of supported media types for the Media Manager
* @var array $imagesExt The supported extensions for images
* @var array $audiosExt The supported extensions for audios
* @var array $videosExt The supported extensions for videos
Expand Down Expand Up @@ -156,6 +157,7 @@

?>
<joomla-field-media class="field-media-wrapper"
types="<?php echo $this->escape(implode(',', $mediaTypeNames)); ?>"
base-path="<?php echo $this->escape(Uri::root()); ?>"
root-folder="<?php echo $this->escape(ComponentHelper::getParams('com_media')->get('file_path', 'images')); ?>"
url="<?php echo $url; ?>"
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Form/Field/MediaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ function ($mediaType) use (&$types, &$imagesAllowedExt, &$audiosAllowedExt, &$vi
'previewHeight' => $this->previewHeight,
'previewWidth' => $this->previewWidth,
'mediaTypes' => implode(',', $types),
'mediaTypeNames' => $mediaTypes,
'imagesExt' => $imagesExt,
'audiosExt' => $audiosExt,
'videosExt' => $videosExt,
Expand Down

0 comments on commit bea594e

Please sign in to comment.