?
Referenced as Pull Request for: # 9466
avatar anibalsanchez
anibalsanchez
17 Mar 2016

Steps to reproduce the issue

I have found the case testing an extension. An image field (that was working in Joomla 3.4) is not working in 3.5.0rc4.

This is the button to choose an image for the image field.

        $remoteUrl = 'index.php?option=com_media&view=images&tmpl=component&asset=com_myextension&author=' . JFactory::getUser()->id . '&fieldid=' . $idTag;
        $buttonId = $idTag . '_btn';

        JHtml::_('bootstrap.modal');
        $control[] = '<a id="' . $buttonId . '" href="#' . $idTag . '_modal" role="button" class="btn" data-toggle="modal" title="' . JText::_('JSELECT') . '">' . JText::_('JSELECT') . '</a>';
        $control[] = JHtmlBootstrap::renderModal(
                $idTag . '_modal',
                array(
                'url' => $remoteUrl,
                'title' => JText::_('JSELECT'),
                'height' => '600px', 'width' => '500px')
        );

Expected result

Selected image file is inserted in the image field.

Actual result

No action

System information (as much as possible)

3.5.0rc4

Additional comments

If Isis view override is removed, then the image selection works OK.

administrator/templates/isis/html/com_media/images/default.php

            <button class="btn btn-success button-save-selected" type="button" <?php if (!$this->state->get('field.id')):?>onclick="ImageManager.onok();window.parent.jModalClose();window.parent.jQuery('.modal.in').modal('hide');"<?php endif;?> data-dismiss="modal"><?php echo JText::_('COM_MEDIA_INSERT') ?></button>

administrator/components/com_media/views/images/tmpl/default.php

            <button class="btn btn-success button-save-selected" type="button" onclick="<?php if ($this->state->get('field.id')):?>window.parent.jInsertFieldValue(document.getElementById('f_url').value,'<?php echo $this->state->get('field.id');?>');<?php else:?>ImageManager.onok();<?php endif;?

@dgt41 ... I remember a related PR ...

avatar anibalsanchez anibalsanchez - open - 17 Mar 2016
avatar anibalsanchez anibalsanchez - change - 17 Mar 2016
The description was changed
avatar anibalsanchez anibalsanchez - change - 17 Mar 2016
Title
Media manager, image selection with fieldid does not work on Isis
Media manager, image selection with fieldid does not work on Isis
avatar wilsonge
wilsonge - comment - 17 Mar 2016

@dgt41 I think this is one for you

avatar wilsonge wilsonge - change - 17 Mar 2016
Labels Added: ?
avatar dgt41
dgt41 - comment - 17 Mar 2016

The button is the one on the modals footer or the one inside the modal?

avatar anibalsanchez
anibalsanchez - comment - 17 Mar 2016

The button inside the modal from media/images that calls the image insertion routine into the field.

avatar brianteeman brianteeman - change - 17 Mar 2016
Category Media Manager
avatar brianteeman brianteeman - change - 17 Mar 2016
Labels
avatar dgt41
dgt41 - comment - 17 Mar 2016

I cannot replicate this! @anibalsanchez is your browser's cache cleared? Which extension failed?

avatar ggppdk
ggppdk - comment - 17 Mar 2016

If Isis view override is removed, then the image selection works OK.

administrator/templates/isis/html/com_media/images/default.php

Yes i confirm this issue,

isis backend template has an template override file ...
administrator/templates/isis/html/com_media/images/default.php

  • which uses modal that is bootstrap based (if i remember correctly)

but com_media component has:
administrator/components/com_media/views/images/tmpl/default.php

  • which uses modal that is mootools based (if i remember correctly)

I have already made a workaround in my extension to load a copy of the component template file ...

JPATH_BASE.'/templates/'.$app->getTemplate().'/html/com_media/images/my_extensionname.php

but there must be several extensions with custom code,

  • that may be effected by this, they will not be able to select media files

[EDIT]
by using creating file: my_extensionname.php i am not breaking anything in isis template or in any other extension

avatar dgt41
dgt41 - comment - 17 Mar 2016

Hmmm @ggppdk that doesn't make much sense:
The field SHOULD work out of the box. The current ISIS override DOESN'T need the onclick call (when a fieldId is passed) as that is done in the mediafield.js.
can you share the xml definition for such a failing field?

avatar ggppdk
ggppdk - comment - 17 Mar 2016

@dgt41
you are right but ...
it is not an XML file not JForm !

I am calling inside media manager inside custom PHP code ...
similar as @anibalsanchez example
and i have seen 1 or 2 other extensions doing this

[EDIT]
which extensions are propably not updated yet

avatar dgt41
dgt41 - comment - 17 Mar 2016

OK, now it makes sense. I will change the code to incorporate such cases

avatar brianteeman brianteeman - change - 17 Mar 2016
Status New Confirmed
Labels
avatar dgt41
dgt41 - comment - 17 Mar 2016

@anibalsanchez @ggppdk @wilsonge This is one of those chicken-egg situation: providing the old JinsertImage() breaks the repeatable field

avatar wilsonge
wilsonge - comment - 17 Mar 2016

OK How exactly are you guys using this field. I know you say PHP - but I need more information to make a decision about b/c. Like honestly my gut is that JFormFields are designed to work through JForm - if you are using things outside of this then we don't offer b/c on that. But willing to study code if you guys feel you are "using" the API correctly :)

avatar ggppdk
ggppdk - comment - 17 Mar 2016

Ok, this is not a complete solution, but maybe duplicate

administrator/components/com_media/views/images/tmpl/default.php
as:
administrator/components/com_media/views/images/tmpl/default_legacy.php

And require that all extensions using custom code to call media manager will need to add to their URL:
&layout=default_legacy

avatar ggppdk
ggppdk - comment - 17 Mar 2016

But i think that there is 1 more problem here:

  • which is bad too: adding an override that uses bootstrap modal in isis template and thus behaves differently than the template file of component, makes little sense and creates another problem

It means that if any site uses a different backend template that does not have an override like isis
then these will break ?

  • media field
  • and repeatable field

[EDIT]
i mean if template was to be changed like this then the change should have been inside the component and not via a template override

avatar ggppdk
ggppdk - comment - 17 Mar 2016

@wilsonge
Because i felt i was not using the API correctly

  • that is why i did not submit an issue here

I am using JForm,

  • but the field is not extending JFormField

About my code:

// We will use the mootools based media manager
JHtml::_('behavior.framework', true);

// Load the modal behavior script.
JHtml::_('behavior.modal'/*, '.fc_image_field_mm_modal'*/);

// Include media field JS, detecting different version of Joomla
if( file_exists($path = JPATH_ROOT.'/media/media/js/mediafield-mootools.min.js') ) $media_js = 'media/mediafield-mootools.min.js';
else if( file_exists($path = JPATH_ROOT.'/media/media/js/mediafield.min.js') ) $media_js = 'media/mediafield.min.js';
else $media_js = 'media/mediafield.js';

JHtml::_('script', $media_js, $mootools_framework = true, $media_folder_relative_path = true, false, false, true);

// Tooltips for image path and image popup preview
JHtml::_('behavior.tooltip', '.hasTipImgpath', array('onShow' => 'jMediaRefreshImgpathTip'));
JHtml::_('behavior.tooltip', '.hasTipPreview', array('onShow' => 'jMediaRefreshPreviewTip'));
...
...
...
$mm_link = 'index.php?option=com_media&amp;view=images&amp;layout=default_fc&amp;tmpl=component&amp;asset=com_flexicontent&amp;author=&amp;fieldid=\'+mm_id+\'&amp;folder=';
$select_existing = '
<div class="'.$input_grp_class.'">
    <div class="media-preview '.$add_on_class.' ">
        '.JHtml::tooltip($tooltip, $tooltip_options).'
    </div>
    <input type="text" name="'.$fieldname_n.'[existingname]" id="'.$mm_id.'" value="'.htmlspecialchars($img_path, ENT_COMPAT, 'UTF-8').'" readonly="readonly"
        class="existingname input-xxlarge field-media-input hasTipImgpath"  title="'.htmlspecialchars('<span id="TipImgpath"></span>', ENT_COMPAT, 'UTF-8').'" data-basepath="'.JUri::root().'"
    />
    <a class="fc_image_field_mm_modal btn '.$tooltip_class.'" title="'.JText::_('FLEXI_SELECT_IMAGE').'" onclick="var mm_id=jQuery(this).parent().find(\'.existingname\').attr(\'id\'); currElement'.$field->id.'=mm_id; SqueezeBox.open(\''.$mm_link.'\', {size:{x: ((screen.width-120) > 1360 ? 1360 : (screen.width-120)), y: ((screen.height-220) > 800 ? 800 : (screen.height-220))}, handler: \'iframe\', onClose: function() { incrementValCnt'.$field->id.'(); } });  return false;">
        '.JText::_('FLEXI_SELECT').'
    </a>
    <a class="btn '.$tooltip_class.'" href="javascript:;" title="'.JText::_('FLEXI_CLEAR').'" onclick="var mm_id=jQuery(this).parent().find(\'.existingname\').attr(\'id\');  clearField'.$field->id.'(this); jInsertFieldValue(\'\', mm_id); return false;" >
        <i class="icon-remove"></i>
    </a>
</div>
';
avatar anibalsanchez
anibalsanchez - comment - 18 Mar 2016

In my case, the original button from media/images fixes the issue.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9454.

avatar anibalsanchez anibalsanchez - reference | b0e68ee - 18 Mar 16
avatar anibalsanchez anibalsanchez - reference | cdce08d - 18 Mar 16
avatar ggppdk
ggppdk - comment - 18 Mar 2016

@anibalsanchez

With your changes in the insert button

  • it works in my case too without using a template override

And now i remember that indeed that was the problem, the changes in the insert button, not the use of bootstrap modal (sorry i recalled wrong)

  • in my case i use Squeezebox modal and it works with the changes that you made in the insert button

So this seems to be backwards compatible.

Does your change break the repeatable field ?

avatar brianteeman
brianteeman - comment - 18 Mar 2016

Closed as we have a PR for testing #9466


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9454.

avatar brianteeman brianteeman - close - 18 Mar 2016
avatar brianteeman brianteeman - change - 18 Mar 2016
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2016-03-18 11:57:59
Closed_By brianteeman
Labels
avatar brianteeman brianteeman - change - 18 Mar 2016
Labels
avatar brianteeman brianteeman - close - 18 Mar 2016
avatar wilsonge wilsonge - close - 18 Mar 2016
avatar wilsonge wilsonge - change - 18 Mar 2016
Labels Removed: ?
avatar nareshvida
nareshvida - comment - 18 Jun 2016

Hi,

I am also facing the same problem with JA Platon theme. It was working fine with Joomla 3.4. The issue cause after Joomla Version update. Kindly help me.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9454.

avatar brianteeman
brianteeman - comment - 18 Jun 2016

@nareshvida you should check with the maker if the template for an update

Add a Comment

Login with GitHub to post a comment