magento 2 admin product image detail custom textfield value gone after dialog close
I override appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
file following below steps.
1) Create module name appcodeHsMageenhancement.
2) Create event.xml file under appcodeHsMageenhancementetc folder.
3) Added below code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_gallery_prepare_layout">
<observer name="change_template" disabled="true"/>
<observer name="admin_product_gallery_change_template" instance="HsMageenhancementObserverChangeTemplateObserver" />
</event>
</config>
4) Create observer.
Added folder Observer and add php file named ChangeTemplateObserver.php
define in event.xml file
Add below code into it.
<?php
namespace HsMageenhancementObserver;
use MagentoFrameworkEventObserverInterface;
class ChangeTemplateObserver implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$observer->getBlock()->setTemplate('Hs_Mageenhancement::helper/gallery.phtml');
}
}
5) Added template file under
Hs/Mageenhancement/view/adminhtml/templates/helper/gallery.phtml
Copy file content from
appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
Added related_tire_price
custom field into exiting code.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$elementName = $block->getElement()->getName() . '[images]';
$formName = $block->getFormName();
?>
<div class="row">
<div class="add-video-button-container">
<button id="add_video_button"
title="<?= $block->escapeHtml(__('Add Video')) ?>"
data-role="add-video-button"
type="button"
class="action-secondary"
data-ui-id="widget-button-1">
<span><?= $block->escapeHtml(__('Add Video')) ?></span>
</button>
</div>
</div>
<?php
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$element = $block->getElement();
$elementToggleCode = $element->getToggleCode() ? $element->getToggleCode() : 'toggleValueElements(this, this.parentNode.parentNode.parentNode)';
?>
<div id="<?= $block->getHtmlId() ?>"
class="gallery"
data-mage-init='{"openVideoModal":{}}'
data-parent-component="<?= $block->escapeHtml($block->getData('config/parentComponent')) ?>"
data-images="<?= $block->escapeHtmlAttr($block->getImagesJson()) ?>"
data-types="<?= $block->escapeHtml(
$this->helper('MagentoFrameworkJsonHelperData')->jsonEncode($block->getImageTypes())
) ?>"
>
<?php
if (!$block->getElement()->getReadonly()):
?>
<div class="image image-placeholder">
<?php /* @escapeNotVerified */ echo $block->getUploaderHtml();
?>
<div class="product-image-wrapper">
<p class="image-placeholder-text">
<?= $block->escapeHtml(
__('Browse to find or drag image here')
); ?>
</p>
</div>
</div>
<?= /* @escapeNotVerified */ $block->getChildHtml('additional_buttons') ?>
<?php
endif;
?>
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<input name="<?= $block->escapeHtml($typeData['name']) ?>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="image-<?= $block->escapeHtml($typeData['code']) ?>"
type="hidden"
value="<?= $block->escapeHtml($typeData['value']) ?>"/>
<?php
endforeach;
?>
<script id="<?= /* @escapeNotVerified */ $block->getHtmlId() ?>-template" data-template="image" type="text/x-magento-template">
<div class="image item <% if (data.disabled == 1) { %>hidden-for-front<% } %> <% if (data.video_url) { %>video-item<% } %>"
data-role="image">
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][position]"
value="<%- data.position %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="position"/>
<% if (data.media_type !== 'external-video') {%>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="image"/>
<% } else { %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
value="<%- data.media_type %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<% } %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_provider]"
value="<%- data.video_provider %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][file]"
value="<%- data.file %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][value_id]"
value="<%- data.value_id %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][related_tire_price]"
value="<%- data.related_tire_price %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][label]"
value="<%- data.label %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
value="<%- data.disabled %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][removed]"
value="" class="is-removed"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_url]"
value="<%- data.video_url %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_title]"
value="<%- data.video_title %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_description]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_metadata]"
value="<%- data.video_metadata %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][role]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<div class="product-image-wrapper">
<img class="product-image"
data-role="image-element"
src="<%- data.url %>"
alt="<%- data.label %>"/>
<div class="actions">
<button type="button"
class="action-remove"
data-role="delete-button"
title="<% if (data.media_type == 'external-video') {%>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<%} else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%}%>">
<span>
<% if (data.media_type == 'external-video') { %>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<% } else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%} %>
</span>
</button>
<div class="draggable-handle"></div>
</div>
<div class="image-fade"><span><?= $block->escapeHtml(
__('Hidden')
); ?></span></div>
</div>
<div class="item-description">
<% if (data.media_type !== 'external-video') {%>
<div class="item-title" data-role="img-title"><%- data.label %></div>
<div class="item-size">
<span data-role="image-dimens"></span>, <span data-role="image-size"><%- data.sizeLabel %></span>
</div>
<% } else { %>
<div class="item-title" data-role="img-title"><%- data.video_title %></div>
<% } %>
</div>
<ul class="item-roles" data-role="roles-labels">
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<li data-role-code="<?= $block->escapeHtml(
$typeData['code']
) ?>" class="item-role item-role-<?= $block->escapeHtml(
$typeData['code']
) ?>">
<?= $block->escapeHtml($typeData['label']) ?>
</li>
<?php
endforeach;
?>
</ul>
</div>
</script>
<script data-role="img-dialog-container-tmpl" type="text/x-magento-template">
<div class="image-panel" data-role="dialog">
</div>
</script>
<script data-role="img-dialog-tmpl" type="text/x-magento-template">
<div class="image-panel-preview">
<img src="<%- data.url %>" alt="<%- data.label %>" />
</div>
<div class="image-panel-controls">
<strong class="image-name"><%- data.label %></strong>
<fieldset class="admin__fieldset fieldset-image-panel">
<div class="admin__field field-image-related-tire-price">
<label class="admin__field-label" for="image-related-tire-price">
<span><?= /* @escapeNotVerified */ __('Related Tire Price') ?></span>
</label>
<div class="admin__field-control">
<input type="text"
data-role="image-related-tire-price"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="admin__control-textbox"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][related_tire_price]"><%- data.related_tire_price %></input>
</div>
</div>
<div class="admin__field field-image-description">
<label class="admin__field-label" for="image-description">
<span><?= /* @escapeNotVerified */ __('Alt Text') ?></span>
</label>
<div class="admin__field-control">
<textarea data-role="image-description"
rows="3"
class="admin__control-textarea"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][label]"><%- data.label %></textarea>
</div>
</div>
<div class="admin__field field-image-role">
<label class="admin__field-label">
<span><?= $block->escapeHtml(
__('Role')
); ?></span>
</label>
<div class="admin__field-control">
<ul class="multiselect-alt">
<?php
foreach ($block->getMediaAttributes() as $attribute) :
?>
<li class="item">
<label>
<input class="image-type"
data-role="type-selector"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
type="checkbox"
value="<?= $block->escapeHtml(
$attribute->getAttributeCode()
) ?>"
/>
<?php /* @escapeNotVerified */ echo $block->escapeHtml(
$attribute->getFrontendLabel()
) ?>
</label>
</li>
<?php
endforeach;
?>
</ul>
</div>
</div>
<div class="admin__field admin__field-inline field-image-size" data-role="size">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Size') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{size}') ?>"></div>
</div>
<div class="admin__field admin__field-inline field-image-resolution" data-role="resolution">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Resolution') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{width}^{height} px') ?>"></div>
</div>
<div class="admin__field field-image-hide">
<div class="admin__field-control">
<div class="admin__field admin__field-option">
<input type="checkbox"
id="hide-from-product-page"
data-role="visibility-trigger"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="1"
class="admin__control-checkbox"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
<% if (data.disabled == 1) { %>checked="checked"<% } %> />
<label for="hide-from-product-page" class="admin__field-label">
<?= $block->escapeHtml(
__('Hide from Product Page')
); ?>
</label>
</div>
</div>
</div>
</fieldset>
</div>
</script>
<div id="<?= /* @noEscape */ $block->getNewVideoBlockName() ?>" style="display:none">
<?= /* @escapeNotVerified */ $block->getFormHtml() ?>
<div id="video-player-preview-location" class="video-player-sidebar">
<div class="video-player-container"></div>
<div class="video-information title">
<label><?= $block->escapeHtml(
__('Title:')
); ?> </label><span></span>
</div>
<div class="video-information uploaded">
<label><?= $block->escapeHtml(
__('Uploaded:')
); ?> </label><span></span>
</div>
<div class="video-information uploader">
<label><?= $block->escapeHtml(
__('Uploader:')
); ?> </label><span></span>
</div>
<div class="video-information duration">
<label><?= $block->escapeHtml(
__('Duration:')
); ?> </label><span></span>
</div>
</div>
</div>
<?= $block->getChildHtml('new-video') ?>
</div>
<script>
jQuery('body').trigger('contentUpdated');
</script>
Now custom text field added successfully but when I close the dialog related_tire_price
value gone.
Is there any additional work require or missing something?
product-images magento2.3.0 modal-popup gallery-image
add a comment |
I override appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
file following below steps.
1) Create module name appcodeHsMageenhancement.
2) Create event.xml file under appcodeHsMageenhancementetc folder.
3) Added below code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_gallery_prepare_layout">
<observer name="change_template" disabled="true"/>
<observer name="admin_product_gallery_change_template" instance="HsMageenhancementObserverChangeTemplateObserver" />
</event>
</config>
4) Create observer.
Added folder Observer and add php file named ChangeTemplateObserver.php
define in event.xml file
Add below code into it.
<?php
namespace HsMageenhancementObserver;
use MagentoFrameworkEventObserverInterface;
class ChangeTemplateObserver implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$observer->getBlock()->setTemplate('Hs_Mageenhancement::helper/gallery.phtml');
}
}
5) Added template file under
Hs/Mageenhancement/view/adminhtml/templates/helper/gallery.phtml
Copy file content from
appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
Added related_tire_price
custom field into exiting code.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$elementName = $block->getElement()->getName() . '[images]';
$formName = $block->getFormName();
?>
<div class="row">
<div class="add-video-button-container">
<button id="add_video_button"
title="<?= $block->escapeHtml(__('Add Video')) ?>"
data-role="add-video-button"
type="button"
class="action-secondary"
data-ui-id="widget-button-1">
<span><?= $block->escapeHtml(__('Add Video')) ?></span>
</button>
</div>
</div>
<?php
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$element = $block->getElement();
$elementToggleCode = $element->getToggleCode() ? $element->getToggleCode() : 'toggleValueElements(this, this.parentNode.parentNode.parentNode)';
?>
<div id="<?= $block->getHtmlId() ?>"
class="gallery"
data-mage-init='{"openVideoModal":{}}'
data-parent-component="<?= $block->escapeHtml($block->getData('config/parentComponent')) ?>"
data-images="<?= $block->escapeHtmlAttr($block->getImagesJson()) ?>"
data-types="<?= $block->escapeHtml(
$this->helper('MagentoFrameworkJsonHelperData')->jsonEncode($block->getImageTypes())
) ?>"
>
<?php
if (!$block->getElement()->getReadonly()):
?>
<div class="image image-placeholder">
<?php /* @escapeNotVerified */ echo $block->getUploaderHtml();
?>
<div class="product-image-wrapper">
<p class="image-placeholder-text">
<?= $block->escapeHtml(
__('Browse to find or drag image here')
); ?>
</p>
</div>
</div>
<?= /* @escapeNotVerified */ $block->getChildHtml('additional_buttons') ?>
<?php
endif;
?>
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<input name="<?= $block->escapeHtml($typeData['name']) ?>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="image-<?= $block->escapeHtml($typeData['code']) ?>"
type="hidden"
value="<?= $block->escapeHtml($typeData['value']) ?>"/>
<?php
endforeach;
?>
<script id="<?= /* @escapeNotVerified */ $block->getHtmlId() ?>-template" data-template="image" type="text/x-magento-template">
<div class="image item <% if (data.disabled == 1) { %>hidden-for-front<% } %> <% if (data.video_url) { %>video-item<% } %>"
data-role="image">
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][position]"
value="<%- data.position %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="position"/>
<% if (data.media_type !== 'external-video') {%>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="image"/>
<% } else { %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
value="<%- data.media_type %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<% } %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_provider]"
value="<%- data.video_provider %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][file]"
value="<%- data.file %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][value_id]"
value="<%- data.value_id %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][related_tire_price]"
value="<%- data.related_tire_price %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][label]"
value="<%- data.label %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
value="<%- data.disabled %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][removed]"
value="" class="is-removed"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_url]"
value="<%- data.video_url %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_title]"
value="<%- data.video_title %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_description]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_metadata]"
value="<%- data.video_metadata %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][role]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<div class="product-image-wrapper">
<img class="product-image"
data-role="image-element"
src="<%- data.url %>"
alt="<%- data.label %>"/>
<div class="actions">
<button type="button"
class="action-remove"
data-role="delete-button"
title="<% if (data.media_type == 'external-video') {%>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<%} else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%}%>">
<span>
<% if (data.media_type == 'external-video') { %>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<% } else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%} %>
</span>
</button>
<div class="draggable-handle"></div>
</div>
<div class="image-fade"><span><?= $block->escapeHtml(
__('Hidden')
); ?></span></div>
</div>
<div class="item-description">
<% if (data.media_type !== 'external-video') {%>
<div class="item-title" data-role="img-title"><%- data.label %></div>
<div class="item-size">
<span data-role="image-dimens"></span>, <span data-role="image-size"><%- data.sizeLabel %></span>
</div>
<% } else { %>
<div class="item-title" data-role="img-title"><%- data.video_title %></div>
<% } %>
</div>
<ul class="item-roles" data-role="roles-labels">
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<li data-role-code="<?= $block->escapeHtml(
$typeData['code']
) ?>" class="item-role item-role-<?= $block->escapeHtml(
$typeData['code']
) ?>">
<?= $block->escapeHtml($typeData['label']) ?>
</li>
<?php
endforeach;
?>
</ul>
</div>
</script>
<script data-role="img-dialog-container-tmpl" type="text/x-magento-template">
<div class="image-panel" data-role="dialog">
</div>
</script>
<script data-role="img-dialog-tmpl" type="text/x-magento-template">
<div class="image-panel-preview">
<img src="<%- data.url %>" alt="<%- data.label %>" />
</div>
<div class="image-panel-controls">
<strong class="image-name"><%- data.label %></strong>
<fieldset class="admin__fieldset fieldset-image-panel">
<div class="admin__field field-image-related-tire-price">
<label class="admin__field-label" for="image-related-tire-price">
<span><?= /* @escapeNotVerified */ __('Related Tire Price') ?></span>
</label>
<div class="admin__field-control">
<input type="text"
data-role="image-related-tire-price"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="admin__control-textbox"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][related_tire_price]"><%- data.related_tire_price %></input>
</div>
</div>
<div class="admin__field field-image-description">
<label class="admin__field-label" for="image-description">
<span><?= /* @escapeNotVerified */ __('Alt Text') ?></span>
</label>
<div class="admin__field-control">
<textarea data-role="image-description"
rows="3"
class="admin__control-textarea"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][label]"><%- data.label %></textarea>
</div>
</div>
<div class="admin__field field-image-role">
<label class="admin__field-label">
<span><?= $block->escapeHtml(
__('Role')
); ?></span>
</label>
<div class="admin__field-control">
<ul class="multiselect-alt">
<?php
foreach ($block->getMediaAttributes() as $attribute) :
?>
<li class="item">
<label>
<input class="image-type"
data-role="type-selector"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
type="checkbox"
value="<?= $block->escapeHtml(
$attribute->getAttributeCode()
) ?>"
/>
<?php /* @escapeNotVerified */ echo $block->escapeHtml(
$attribute->getFrontendLabel()
) ?>
</label>
</li>
<?php
endforeach;
?>
</ul>
</div>
</div>
<div class="admin__field admin__field-inline field-image-size" data-role="size">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Size') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{size}') ?>"></div>
</div>
<div class="admin__field admin__field-inline field-image-resolution" data-role="resolution">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Resolution') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{width}^{height} px') ?>"></div>
</div>
<div class="admin__field field-image-hide">
<div class="admin__field-control">
<div class="admin__field admin__field-option">
<input type="checkbox"
id="hide-from-product-page"
data-role="visibility-trigger"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="1"
class="admin__control-checkbox"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
<% if (data.disabled == 1) { %>checked="checked"<% } %> />
<label for="hide-from-product-page" class="admin__field-label">
<?= $block->escapeHtml(
__('Hide from Product Page')
); ?>
</label>
</div>
</div>
</div>
</fieldset>
</div>
</script>
<div id="<?= /* @noEscape */ $block->getNewVideoBlockName() ?>" style="display:none">
<?= /* @escapeNotVerified */ $block->getFormHtml() ?>
<div id="video-player-preview-location" class="video-player-sidebar">
<div class="video-player-container"></div>
<div class="video-information title">
<label><?= $block->escapeHtml(
__('Title:')
); ?> </label><span></span>
</div>
<div class="video-information uploaded">
<label><?= $block->escapeHtml(
__('Uploaded:')
); ?> </label><span></span>
</div>
<div class="video-information uploader">
<label><?= $block->escapeHtml(
__('Uploader:')
); ?> </label><span></span>
</div>
<div class="video-information duration">
<label><?= $block->escapeHtml(
__('Duration:')
); ?> </label><span></span>
</div>
</div>
</div>
<?= $block->getChildHtml('new-video') ?>
</div>
<script>
jQuery('body').trigger('contentUpdated');
</script>
Now custom text field added successfully but when I close the dialog related_tire_price
value gone.
Is there any additional work require or missing something?
product-images magento2.3.0 modal-popup gallery-image
add a comment |
I override appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
file following below steps.
1) Create module name appcodeHsMageenhancement.
2) Create event.xml file under appcodeHsMageenhancementetc folder.
3) Added below code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_gallery_prepare_layout">
<observer name="change_template" disabled="true"/>
<observer name="admin_product_gallery_change_template" instance="HsMageenhancementObserverChangeTemplateObserver" />
</event>
</config>
4) Create observer.
Added folder Observer and add php file named ChangeTemplateObserver.php
define in event.xml file
Add below code into it.
<?php
namespace HsMageenhancementObserver;
use MagentoFrameworkEventObserverInterface;
class ChangeTemplateObserver implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$observer->getBlock()->setTemplate('Hs_Mageenhancement::helper/gallery.phtml');
}
}
5) Added template file under
Hs/Mageenhancement/view/adminhtml/templates/helper/gallery.phtml
Copy file content from
appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
Added related_tire_price
custom field into exiting code.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$elementName = $block->getElement()->getName() . '[images]';
$formName = $block->getFormName();
?>
<div class="row">
<div class="add-video-button-container">
<button id="add_video_button"
title="<?= $block->escapeHtml(__('Add Video')) ?>"
data-role="add-video-button"
type="button"
class="action-secondary"
data-ui-id="widget-button-1">
<span><?= $block->escapeHtml(__('Add Video')) ?></span>
</button>
</div>
</div>
<?php
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$element = $block->getElement();
$elementToggleCode = $element->getToggleCode() ? $element->getToggleCode() : 'toggleValueElements(this, this.parentNode.parentNode.parentNode)';
?>
<div id="<?= $block->getHtmlId() ?>"
class="gallery"
data-mage-init='{"openVideoModal":{}}'
data-parent-component="<?= $block->escapeHtml($block->getData('config/parentComponent')) ?>"
data-images="<?= $block->escapeHtmlAttr($block->getImagesJson()) ?>"
data-types="<?= $block->escapeHtml(
$this->helper('MagentoFrameworkJsonHelperData')->jsonEncode($block->getImageTypes())
) ?>"
>
<?php
if (!$block->getElement()->getReadonly()):
?>
<div class="image image-placeholder">
<?php /* @escapeNotVerified */ echo $block->getUploaderHtml();
?>
<div class="product-image-wrapper">
<p class="image-placeholder-text">
<?= $block->escapeHtml(
__('Browse to find or drag image here')
); ?>
</p>
</div>
</div>
<?= /* @escapeNotVerified */ $block->getChildHtml('additional_buttons') ?>
<?php
endif;
?>
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<input name="<?= $block->escapeHtml($typeData['name']) ?>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="image-<?= $block->escapeHtml($typeData['code']) ?>"
type="hidden"
value="<?= $block->escapeHtml($typeData['value']) ?>"/>
<?php
endforeach;
?>
<script id="<?= /* @escapeNotVerified */ $block->getHtmlId() ?>-template" data-template="image" type="text/x-magento-template">
<div class="image item <% if (data.disabled == 1) { %>hidden-for-front<% } %> <% if (data.video_url) { %>video-item<% } %>"
data-role="image">
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][position]"
value="<%- data.position %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="position"/>
<% if (data.media_type !== 'external-video') {%>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="image"/>
<% } else { %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
value="<%- data.media_type %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<% } %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_provider]"
value="<%- data.video_provider %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][file]"
value="<%- data.file %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][value_id]"
value="<%- data.value_id %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][related_tire_price]"
value="<%- data.related_tire_price %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][label]"
value="<%- data.label %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
value="<%- data.disabled %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][removed]"
value="" class="is-removed"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_url]"
value="<%- data.video_url %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_title]"
value="<%- data.video_title %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_description]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_metadata]"
value="<%- data.video_metadata %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][role]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<div class="product-image-wrapper">
<img class="product-image"
data-role="image-element"
src="<%- data.url %>"
alt="<%- data.label %>"/>
<div class="actions">
<button type="button"
class="action-remove"
data-role="delete-button"
title="<% if (data.media_type == 'external-video') {%>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<%} else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%}%>">
<span>
<% if (data.media_type == 'external-video') { %>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<% } else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%} %>
</span>
</button>
<div class="draggable-handle"></div>
</div>
<div class="image-fade"><span><?= $block->escapeHtml(
__('Hidden')
); ?></span></div>
</div>
<div class="item-description">
<% if (data.media_type !== 'external-video') {%>
<div class="item-title" data-role="img-title"><%- data.label %></div>
<div class="item-size">
<span data-role="image-dimens"></span>, <span data-role="image-size"><%- data.sizeLabel %></span>
</div>
<% } else { %>
<div class="item-title" data-role="img-title"><%- data.video_title %></div>
<% } %>
</div>
<ul class="item-roles" data-role="roles-labels">
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<li data-role-code="<?= $block->escapeHtml(
$typeData['code']
) ?>" class="item-role item-role-<?= $block->escapeHtml(
$typeData['code']
) ?>">
<?= $block->escapeHtml($typeData['label']) ?>
</li>
<?php
endforeach;
?>
</ul>
</div>
</script>
<script data-role="img-dialog-container-tmpl" type="text/x-magento-template">
<div class="image-panel" data-role="dialog">
</div>
</script>
<script data-role="img-dialog-tmpl" type="text/x-magento-template">
<div class="image-panel-preview">
<img src="<%- data.url %>" alt="<%- data.label %>" />
</div>
<div class="image-panel-controls">
<strong class="image-name"><%- data.label %></strong>
<fieldset class="admin__fieldset fieldset-image-panel">
<div class="admin__field field-image-related-tire-price">
<label class="admin__field-label" for="image-related-tire-price">
<span><?= /* @escapeNotVerified */ __('Related Tire Price') ?></span>
</label>
<div class="admin__field-control">
<input type="text"
data-role="image-related-tire-price"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="admin__control-textbox"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][related_tire_price]"><%- data.related_tire_price %></input>
</div>
</div>
<div class="admin__field field-image-description">
<label class="admin__field-label" for="image-description">
<span><?= /* @escapeNotVerified */ __('Alt Text') ?></span>
</label>
<div class="admin__field-control">
<textarea data-role="image-description"
rows="3"
class="admin__control-textarea"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][label]"><%- data.label %></textarea>
</div>
</div>
<div class="admin__field field-image-role">
<label class="admin__field-label">
<span><?= $block->escapeHtml(
__('Role')
); ?></span>
</label>
<div class="admin__field-control">
<ul class="multiselect-alt">
<?php
foreach ($block->getMediaAttributes() as $attribute) :
?>
<li class="item">
<label>
<input class="image-type"
data-role="type-selector"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
type="checkbox"
value="<?= $block->escapeHtml(
$attribute->getAttributeCode()
) ?>"
/>
<?php /* @escapeNotVerified */ echo $block->escapeHtml(
$attribute->getFrontendLabel()
) ?>
</label>
</li>
<?php
endforeach;
?>
</ul>
</div>
</div>
<div class="admin__field admin__field-inline field-image-size" data-role="size">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Size') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{size}') ?>"></div>
</div>
<div class="admin__field admin__field-inline field-image-resolution" data-role="resolution">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Resolution') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{width}^{height} px') ?>"></div>
</div>
<div class="admin__field field-image-hide">
<div class="admin__field-control">
<div class="admin__field admin__field-option">
<input type="checkbox"
id="hide-from-product-page"
data-role="visibility-trigger"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="1"
class="admin__control-checkbox"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
<% if (data.disabled == 1) { %>checked="checked"<% } %> />
<label for="hide-from-product-page" class="admin__field-label">
<?= $block->escapeHtml(
__('Hide from Product Page')
); ?>
</label>
</div>
</div>
</div>
</fieldset>
</div>
</script>
<div id="<?= /* @noEscape */ $block->getNewVideoBlockName() ?>" style="display:none">
<?= /* @escapeNotVerified */ $block->getFormHtml() ?>
<div id="video-player-preview-location" class="video-player-sidebar">
<div class="video-player-container"></div>
<div class="video-information title">
<label><?= $block->escapeHtml(
__('Title:')
); ?> </label><span></span>
</div>
<div class="video-information uploaded">
<label><?= $block->escapeHtml(
__('Uploaded:')
); ?> </label><span></span>
</div>
<div class="video-information uploader">
<label><?= $block->escapeHtml(
__('Uploader:')
); ?> </label><span></span>
</div>
<div class="video-information duration">
<label><?= $block->escapeHtml(
__('Duration:')
); ?> </label><span></span>
</div>
</div>
</div>
<?= $block->getChildHtml('new-video') ?>
</div>
<script>
jQuery('body').trigger('contentUpdated');
</script>
Now custom text field added successfully but when I close the dialog related_tire_price
value gone.
Is there any additional work require or missing something?
product-images magento2.3.0 modal-popup gallery-image
I override appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
file following below steps.
1) Create module name appcodeHsMageenhancement.
2) Create event.xml file under appcodeHsMageenhancementetc folder.
3) Added below code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_gallery_prepare_layout">
<observer name="change_template" disabled="true"/>
<observer name="admin_product_gallery_change_template" instance="HsMageenhancementObserverChangeTemplateObserver" />
</event>
</config>
4) Create observer.
Added folder Observer and add php file named ChangeTemplateObserver.php
define in event.xml file
Add below code into it.
<?php
namespace HsMageenhancementObserver;
use MagentoFrameworkEventObserverInterface;
class ChangeTemplateObserver implements ObserverInterface
{
public function execute(MagentoFrameworkEventObserver $observer)
{
$observer->getBlock()->setTemplate('Hs_Mageenhancement::helper/gallery.phtml');
}
}
5) Added template file under
Hs/Mageenhancement/view/adminhtml/templates/helper/gallery.phtml
Copy file content from
appcodeMagentoProductVideoviewadminhtmltemplateshelpergallery.phtml
Added related_tire_price
custom field into exiting code.
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$elementName = $block->getElement()->getName() . '[images]';
$formName = $block->getFormName();
?>
<div class="row">
<div class="add-video-button-container">
<button id="add_video_button"
title="<?= $block->escapeHtml(__('Add Video')) ?>"
data-role="add-video-button"
type="button"
class="action-secondary"
data-ui-id="widget-button-1">
<span><?= $block->escapeHtml(__('Add Video')) ?></span>
</button>
</div>
</div>
<?php
/** @var $block MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent */
$element = $block->getElement();
$elementToggleCode = $element->getToggleCode() ? $element->getToggleCode() : 'toggleValueElements(this, this.parentNode.parentNode.parentNode)';
?>
<div id="<?= $block->getHtmlId() ?>"
class="gallery"
data-mage-init='{"openVideoModal":{}}'
data-parent-component="<?= $block->escapeHtml($block->getData('config/parentComponent')) ?>"
data-images="<?= $block->escapeHtmlAttr($block->getImagesJson()) ?>"
data-types="<?= $block->escapeHtml(
$this->helper('MagentoFrameworkJsonHelperData')->jsonEncode($block->getImageTypes())
) ?>"
>
<?php
if (!$block->getElement()->getReadonly()):
?>
<div class="image image-placeholder">
<?php /* @escapeNotVerified */ echo $block->getUploaderHtml();
?>
<div class="product-image-wrapper">
<p class="image-placeholder-text">
<?= $block->escapeHtml(
__('Browse to find or drag image here')
); ?>
</p>
</div>
</div>
<?= /* @escapeNotVerified */ $block->getChildHtml('additional_buttons') ?>
<?php
endif;
?>
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<input name="<?= $block->escapeHtml($typeData['name']) ?>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="image-<?= $block->escapeHtml($typeData['code']) ?>"
type="hidden"
value="<?= $block->escapeHtml($typeData['value']) ?>"/>
<?php
endforeach;
?>
<script id="<?= /* @escapeNotVerified */ $block->getHtmlId() ?>-template" data-template="image" type="text/x-magento-template">
<div class="image item <% if (data.disabled == 1) { %>hidden-for-front<% } %> <% if (data.video_url) { %>video-item<% } %>"
data-role="image">
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][position]"
value="<%- data.position %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="position"/>
<% if (data.media_type !== 'external-video') {%>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="image"/>
<% } else { %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][media_type]"
value="<%- data.media_type %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<% } %>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_provider]"
value="<%- data.video_provider %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][file]"
value="<%- data.file %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][value_id]"
value="<%- data.value_id %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][related_tire_price]"
value="<%- data.related_tire_price %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][label]"
value="<%- data.label %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
value="<%- data.disabled %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][removed]"
value="" class="is-removed"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_url]"
value="<%- data.video_url %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_title]"
value="<%- data.video_title %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_description]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][video_metadata]"
value="<%- data.video_metadata %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<input type="hidden"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][role]"
value="<%- data.video_description %>"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"/>
<div class="product-image-wrapper">
<img class="product-image"
data-role="image-element"
src="<%- data.url %>"
alt="<%- data.label %>"/>
<div class="actions">
<button type="button"
class="action-remove"
data-role="delete-button"
title="<% if (data.media_type == 'external-video') {%>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<%} else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%}%>">
<span>
<% if (data.media_type == 'external-video') { %>
<?= $block->escapeHtml(
__('Delete video')
); ?>
<% } else {%>
<?= $block->escapeHtml(
__('Delete image')
); ?>
<%} %>
</span>
</button>
<div class="draggable-handle"></div>
</div>
<div class="image-fade"><span><?= $block->escapeHtml(
__('Hidden')
); ?></span></div>
</div>
<div class="item-description">
<% if (data.media_type !== 'external-video') {%>
<div class="item-title" data-role="img-title"><%- data.label %></div>
<div class="item-size">
<span data-role="image-dimens"></span>, <span data-role="image-size"><%- data.sizeLabel %></span>
</div>
<% } else { %>
<div class="item-title" data-role="img-title"><%- data.video_title %></div>
<% } %>
</div>
<ul class="item-roles" data-role="roles-labels">
<?php
foreach ($block->getImageTypes() as $typeData):
?>
<li data-role-code="<?= $block->escapeHtml(
$typeData['code']
) ?>" class="item-role item-role-<?= $block->escapeHtml(
$typeData['code']
) ?>">
<?= $block->escapeHtml($typeData['label']) ?>
</li>
<?php
endforeach;
?>
</ul>
</div>
</script>
<script data-role="img-dialog-container-tmpl" type="text/x-magento-template">
<div class="image-panel" data-role="dialog">
</div>
</script>
<script data-role="img-dialog-tmpl" type="text/x-magento-template">
<div class="image-panel-preview">
<img src="<%- data.url %>" alt="<%- data.label %>" />
</div>
<div class="image-panel-controls">
<strong class="image-name"><%- data.label %></strong>
<fieldset class="admin__fieldset fieldset-image-panel">
<div class="admin__field field-image-related-tire-price">
<label class="admin__field-label" for="image-related-tire-price">
<span><?= /* @escapeNotVerified */ __('Related Tire Price') ?></span>
</label>
<div class="admin__field-control">
<input type="text"
data-role="image-related-tire-price"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
class="admin__control-textbox"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][related_tire_price]"><%- data.related_tire_price %></input>
</div>
</div>
<div class="admin__field field-image-description">
<label class="admin__field-label" for="image-description">
<span><?= /* @escapeNotVerified */ __('Alt Text') ?></span>
</label>
<div class="admin__field-control">
<textarea data-role="image-description"
rows="3"
class="admin__control-textarea"
name="<?php /* @escapeNotVerified */
echo $elementName
?>[<%- data.file_id %>][label]"><%- data.label %></textarea>
</div>
</div>
<div class="admin__field field-image-role">
<label class="admin__field-label">
<span><?= $block->escapeHtml(
__('Role')
); ?></span>
</label>
<div class="admin__field-control">
<ul class="multiselect-alt">
<?php
foreach ($block->getMediaAttributes() as $attribute) :
?>
<li class="item">
<label>
<input class="image-type"
data-role="type-selector"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
type="checkbox"
value="<?= $block->escapeHtml(
$attribute->getAttributeCode()
) ?>"
/>
<?php /* @escapeNotVerified */ echo $block->escapeHtml(
$attribute->getFrontendLabel()
) ?>
</label>
</li>
<?php
endforeach;
?>
</ul>
</div>
</div>
<div class="admin__field admin__field-inline field-image-size" data-role="size">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Size') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{size}') ?>"></div>
</div>
<div class="admin__field admin__field-inline field-image-resolution" data-role="resolution">
<label class="admin__field-label">
<span><?= /* @escapeNotVerified */ __('Image Resolution') ?></span>
</label>
<div class="admin__field-value" data-message="<?= /* @escapeNotVerified */ __('{width}^{height} px') ?>"></div>
</div>
<div class="admin__field field-image-hide">
<div class="admin__field-control">
<div class="admin__field admin__field-option">
<input type="checkbox"
id="hide-from-product-page"
data-role="visibility-trigger"
data-form-part="<?= /* @escapeNotVerified */ $formName ?>"
value="1"
class="admin__control-checkbox"
name="<?= /* @escapeNotVerified */ $elementName ?>[<%- data.file_id %>][disabled]"
<% if (data.disabled == 1) { %>checked="checked"<% } %> />
<label for="hide-from-product-page" class="admin__field-label">
<?= $block->escapeHtml(
__('Hide from Product Page')
); ?>
</label>
</div>
</div>
</div>
</fieldset>
</div>
</script>
<div id="<?= /* @noEscape */ $block->getNewVideoBlockName() ?>" style="display:none">
<?= /* @escapeNotVerified */ $block->getFormHtml() ?>
<div id="video-player-preview-location" class="video-player-sidebar">
<div class="video-player-container"></div>
<div class="video-information title">
<label><?= $block->escapeHtml(
__('Title:')
); ?> </label><span></span>
</div>
<div class="video-information uploaded">
<label><?= $block->escapeHtml(
__('Uploaded:')
); ?> </label><span></span>
</div>
<div class="video-information uploader">
<label><?= $block->escapeHtml(
__('Uploader:')
); ?> </label><span></span>
</div>
<div class="video-information duration">
<label><?= $block->escapeHtml(
__('Duration:')
); ?> </label><span></span>
</div>
</div>
</div>
<?= $block->getChildHtml('new-video') ?>
</div>
<script>
jQuery('body').trigger('contentUpdated');
</script>
Now custom text field added successfully but when I close the dialog related_tire_price
value gone.
Is there any additional work require or missing something?
product-images magento2.3.0 modal-popup gallery-image
product-images magento2.3.0 modal-popup gallery-image
asked 1 min ago
Hiren ShahHiren Shah
4018
4018
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264398%2fmagento-2-admin-product-image-detail-custom-textfield-value-gone-after-dialog-cl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264398%2fmagento-2-admin-product-image-detail-custom-textfield-value-gone-after-dialog-cl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown