User tests: Successful: Unsuccessful:
Pull Request for Issue #9454.
The original button from media/images fixes the issue in the case I have found.
Paste the following same code to generate a button to choose an image and fill the name field of a user in administrator/components/com_users/views/user/tmpl/edit.php
Before the patch, in J3.5 RC4, the image can't be inserted in the name field.
After the patch, when you select an image and Insert it, the file name replaces the user name.
$idTag = 'jform_name';
$remoteUrl = 'index.php?option=com_media&view=images&tmpl=component&asset=com_users&author=' . JFactory::getUser()->id . '&fieldid=' . $idTag;
$buttonId = $idTag . '_btn';
JHtml::_('bootstrap.modal');
$test_control[] = '<a id="' . $buttonId . '" href="#' . $idTag . '_modal" role="button" class="btn" data-toggle="modal" title="' . JText::_('JSELECT') . '">' . JText::_('JSELECT') . '</a>';
$test_control[] = JHtmlBootstrap::renderModal(
$idTag . '_modal',
array(
'url' => $remoteUrl,
'title' => JText::_('JSELECT'),
'height' => '600px', 'width' => '500px')
);
echo implode('', $test_control);
JFactory::getDocument()->addScriptDeclaration("
window.jInsertFieldValue = function(value, id) {jQuery('#' + id).val(value);};
window.jModalClose = function() {jQuery('div.modal').modal('hide');};
");
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Media Manager |
Rel_Number | 0 | ⇒ | 9454 |
Relation Type | ⇒ | Pull Request for |
Labels |
Added:
?
|
@dgt41 @ggppdk please, test to confirm it is a viable fix.
I have tested this item successfully on cdce08d
I pasted the code snippet between php tags at the end of administrator/components/com_users/views/user/tmpl/edit.php, but also at the end of administrator/templates/hathor/html/com_users/user/edit.php before last closing div.
Before patch: Works for Hathor but not for Isis.
After patch: Works for both Hathor and Isis.
@anibalsanchez I get an error for normal form fields:
May I ask why you don't do something like:
$idTag = 'form_name';
$extraData = array(
'disabled' => false,
'value' => '',
'asset' => 'asset',
'readonly' => false,
'id' => 'someId',
'name' => 'name',
'authorField' => 'author',
'authorId' => JFactory::getUser()->id,
'folder' => '',
'link' => 'index.php?option=com_media&view=images&tmpl=component&asset=com_users&author=' . JFactory::getUser()->id . '&fieldid=' . $idTag,
'preview' => '',
'previewHeight' => '',
'previewWidth' => '',
);
echo JLayoutHelper::render('joomla.form.field.media', $extraData);
This way you don;t mess mess with the internals of the field and it will work fine in all cases
@JoomliC The root/layouts file is the one with mootools modal, the overrides are the ones for bootstrap. The difference is that the bootstrap javascript is different than that we had for mootools and the reason was to make it compatible with the new repeatable field.
Also (if I am not mistaken) the bootstrap also got tabs for selecting or uploading a file
I thought that will be B/C, because there are templates out there that don't use bootstrap (although we can load it in the field :( )
@dgt41Sure, this media button call can be improved with the latest JLayouts improvements.
I have submitted the issue to fix the legacy API support. I guess there are many extensions still implementing the old way.
@dgt41 About the console error, I've been unable to reproduce it. It can be fixed in this way:
<button class="btn btn-success button-save-selected" type="button" onclick="<?php if ($this->state->get('field.id')):?>((window.parent.jInsertFieldValue) && (window.parent.jInsertFieldValue(document.getElementById('f_url').value,'<?php echo $this->state->get('field.id');?>')));<?php else:?>ImageManager.onok();<?php endif;?>window.parent.jModalClose();window.parent.jQuery('.modal.in').modal('hide');" data-dismiss="modal"><?php echo JText::_('COM_MEDIA_INSERT') ?></button>
But, it also affects media/images (from where I copy/pasted the button).
5'... I'm adding the condition.
This PR has received new commits.
CC: @richard67
@anibalsanchez can you update protostar layout as well?
This PR has received new commits.
CC: @richard67
This PR has received new commits.
CC: @richard67
Ready to be tested. @richard67 @dgt41 @JoomliC @ggppdk
Cases:
I have tested this item successfully on 6fab638
Tested all test cases mentioned in comment above.
Works as desired, no php errors or warning with maximum error reporting.
I have tested this item successfully on 6fab638
- Backend. New article, image selection from editor
Worked as described - Thanks!
Status | Pending | ⇒ | Ready to Commit |
Labels |
Labels |
Added:
?
|
I have tested this item successfully on 6fab638
Tested cases, and other extensions using image field, with success.
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-03-20 18:28:51 |
Closed_By | ⇒ | wilsonge |
Labels |
Removed:
?
|
:( Thats a shame the change to using separate tabs was an improvement
On 20 March 2016 at 18:29, George Wilson notifications@github.com wrote:
After discussion with @dgt41 https://github.com/dgt41 we are just going
to remove the template overrides for b/c reasons and stick with the
mootools stuff—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#9466 (comment)
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
@brianteeman A minor note, #9454 has "label:3.5.0-blocker". Does this one inherit the same label?
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9466.