Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add new params to media field: preview_width / preview_height #1187

Merged
merged 2 commits into from

3 participants

@benjaminpick

Improvement of #1105 : Allowing full-size preview.

Benjamin Pick added some commits
Benjamin Pick Add new params to media field: preview_width / preview_height
(Allowing full-size preview)
c1ba28c
Benjamin Pick fix phpcs 6380e52
@timoline

Hi, ok thx
I tested it, but directory="folder" isnt working correct for me anymore,
I mean: when pressing select it not goes to the folder.........can you can confirm that?
if I change back the code to:(line 130)
array_shift($folder);

it works ok....but maybe it has someting todo with the getParams('com_media') setting

Also a new param "default" would be nice

default = the default image to use

@benjaminpick
@timoline

Hi, I read it a few times, but I think the first one

Just show the image which is set by default, when the user select a new image then show the new image
The default value is like a placeholder

@benjaminpick

For the directory-Folder-Bug: Which exactly are your values in the XML as well as the getParams('com_media') ? It should be a regression of #728 .

@timoline
        <field
            name="logo_small"
            type="media"            
            label="COM_JOOMLEAGUE_ADMIN_CLUB_LOGO_SMALL"
            description="COM_JOOMLEAGUE_ADMIN_CLUB_LOGO_SMALL_DESC"
            class="inputbox"
            preview="yes"
            directory="/com_joomleague/database/clubs/small"/>  

echo JComponentHelper::getParams('com_media')->get('image_path', 'images');

images

@benjaminpick

From documentation: "This attribute should be relative to the top level /images/ folder." http://docs.joomla.org/Media_form_field_type

@chdemko chdemko merged commit 27eaaba into joomla:staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 4, 2012
  1. Add new params to media field: preview_width / preview_height

    Benjamin Pick authored
    (Allowing full-size preview)
  2. fix phpcs

    Benjamin Pick authored
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 2 deletions.
  1. +10 −2 libraries/legacy/form/field/media.php
View
12 libraries/legacy/form/field/media.php
@@ -92,11 +92,12 @@ protected function getInput()
$script[] = ' function jMediaRefreshPreviewTip(tip)';
$script[] = ' {';
- $script[] = ' tip.setStyle("display", "block");';
$script[] = ' var img = tip.getElement("img.media-preview");';
+ $script[] = ' tip.getElement("div.tip").setStyle("max-width", "none");';
$script[] = ' var id = img.getProperty("id");';
$script[] = ' id = id.substring(0, id.length - "_preview".length);';
$script[] = ' jMediaRefreshPreview(id);';
+ $script[] = ' tip.setStyle("display", "block");';
$script[] = ' }';
// Add the script to the document head.
@@ -138,6 +139,7 @@ protected function getInput()
{
$folder = '';
}
+
// The button.
if ($this->element['disabled'] != true)
{
@@ -198,10 +200,16 @@ protected function getInput()
$src = '';
}
+ $width = isset($this->element['preview_width']) ? (int) $this->element['preview_width'] : 300;
+ $height = isset($this->element['preview_height']) ? (int) $this->element['preview_height'] : 200;
+ $style = '';
+ $style .= ($width > 0) ? 'max-width:' . $width . 'px;' : '';
+ $style .= ($height > 0) ? 'max-height:' . $height . 'px;' : '';
+
$attr = array(
'id' => $this->id . '_preview',
'class' => 'media-preview',
- 'style' => 'max-width:160px; max-height:100px;'
+ 'style' => $style,
);
$img = JHtml::image($src, JText::_('JLIB_FORM_MEDIA_PREVIEW_ALT'), $attr);
$previewImg = '<div id="' . $this->id . '_preview_img"' . ($src ? '' : ' style="display:none"') . '>' . $img . '</div>';
Something went wrong with that request. Please try again.