How to get imageUrl using Jquery in magento2?How can i rewrite TierPrice Block in Magento2Magento 2 : How can I upload files of dynamically added file input fields in the adminMagento 2 Add new field to Magento_User admin formjquery Issue with magento2.3 backendUnable to initialize external jQuery in Magento2how to get value of selected option using jqueryHow to create custom form in Magento 2.2.3How to setContent in wysiwyg editor using JQuery in magento2?How to hide upload file field using jquery in magento2
Up arrow under a sequence
How can I tell if I have simplified my talk too much?
Why do non-aerobatic aircraft have a negative G limit?
Are ^ and _ the only commands in LaTeX not preceded by a backslash?
Is 2FA via mobile phone still a good idea when phones are the most exposed device?
Print your char count in words, in many languages
Trading stock more quickly vs. holding it
What does it mean to support the brexit deal but need more time to scrutinise it?
What is this hole on the left wing of the Eurofighter Typhoon?
Finding big cacti between Phoenix, Las Vegas, and Los Angeles
Will the price change on Airbnb if I provide my ID later?
Can an MP who didn't vote for the 2nd reading of a bill propose amendments to it?
Got an email saying my password is weak, reason for concern?
Power supply - purpose of the capacitor on the side of the transformer before full bridge rectifier
How do we distinguish old craters from new ones on the Moon?
Are snow shoes useful in mountaineering?
ASCII Expansion
"When you Frankenstein a team together..." - Is "Frankenstein" a new verb?
What is the most life you can have at the end of your first turn with only three cards?
"bees" -> "hive" in 5 letter changes or fewer
Practically, how does an 'observer' collapse a wave function?
Can a stolen Android phone with USB debugging enabled have screen lock bypassed?
How to write the sum of function inside LaTeX?
Emacs busy while evaluating R in ESS
How to get imageUrl using Jquery in magento2?
How can i rewrite TierPrice Block in Magento2Magento 2 : How can I upload files of dynamically added file input fields in the adminMagento 2 Add new field to Magento_User admin formjquery Issue with magento2.3 backendUnable to initialize external jQuery in Magento2how to get value of selected option using jqueryHow to create custom form in Magento 2.2.3How to setContent in wysiwyg editor using JQuery in magento2?How to hide upload file field using jquery in magento2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I want to change Image src using jquery in magento2,
So how can I get Imageurl in jQuery?
<field name="default_template">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">KtplBannerManagementModelConfigSourceTemplate</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Demo template</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">select</item>
<item name="formElement" xsi:type="string">select</item>
<item name="dataScope" xsi:type="string">default_template</item>
<item name="component" xsi:type="string">Ktpl_BannerManagement/js/form/element/defaultTemplate</item>
</item>
</argument>
</field>
<field name="default_image">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">input</item>
<item name="elementTmpl" xsi:type="string">Ktpl_BannerManagement/form/element/defaultTemplate</item>
</item>
</argument>
</field>
defaultTemplate.html
<img alt="demo" class="article_image" id="mp-demo-image">
<div class="admin__field field field-load_template " data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-form-field-load-template" style="">
<label class="label admin__field-label" for="banner_load_template" data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-note-banner-label"><span></span></label>
<div class="admin__field-control control">
<div id="banner_load_template" class="control-value admin__field-value" style=""><button id="id_lq27ZKqKzkY3i4p7JLoi57aNy7f2PDSk" title="Load Template" type="button" class="action-default scalable" data-ui-id="widget-button-0">
<span>Load Template</span>
</button>
</div>
</div>
</div>
if I will update default_template value I want to change default_image src using jQuery
magento2 magento2.3
|
show 3 more comments
I want to change Image src using jquery in magento2,
So how can I get Imageurl in jQuery?
<field name="default_template">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">KtplBannerManagementModelConfigSourceTemplate</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Demo template</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">select</item>
<item name="formElement" xsi:type="string">select</item>
<item name="dataScope" xsi:type="string">default_template</item>
<item name="component" xsi:type="string">Ktpl_BannerManagement/js/form/element/defaultTemplate</item>
</item>
</argument>
</field>
<field name="default_image">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">input</item>
<item name="elementTmpl" xsi:type="string">Ktpl_BannerManagement/form/element/defaultTemplate</item>
</item>
</argument>
</field>
defaultTemplate.html
<img alt="demo" class="article_image" id="mp-demo-image">
<div class="admin__field field field-load_template " data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-form-field-load-template" style="">
<label class="label admin__field-label" for="banner_load_template" data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-note-banner-label"><span></span></label>
<div class="admin__field-control control">
<div id="banner_load_template" class="control-value admin__field-value" style=""><button id="id_lq27ZKqKzkY3i4p7JLoi57aNy7f2PDSk" title="Load Template" type="button" class="action-default scalable" data-ui-id="widget-button-0">
<span>Load Template</span>
</button>
</div>
</div>
</div>
if I will update default_template value I want to change default_image src using jQuery
magento2 magento2.3
2
Do you need it in .phtml file or seperate JS file ?
– Aasim Goriya
Jun 14 at 10:48
In custom js file @AasimGoriya
– Rutvee Sojitra
Jun 14 at 11:05
Please check my ans.
– Aasim Goriya
Jun 14 at 11:13
but i want it in admin ui form
– Rutvee Sojitra
Jun 14 at 11:18
do you have .phtml file for your admin form page ?
– Aasim Goriya
Jun 14 at 11:19
|
show 3 more comments
I want to change Image src using jquery in magento2,
So how can I get Imageurl in jQuery?
<field name="default_template">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">KtplBannerManagementModelConfigSourceTemplate</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Demo template</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">select</item>
<item name="formElement" xsi:type="string">select</item>
<item name="dataScope" xsi:type="string">default_template</item>
<item name="component" xsi:type="string">Ktpl_BannerManagement/js/form/element/defaultTemplate</item>
</item>
</argument>
</field>
<field name="default_image">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">input</item>
<item name="elementTmpl" xsi:type="string">Ktpl_BannerManagement/form/element/defaultTemplate</item>
</item>
</argument>
</field>
defaultTemplate.html
<img alt="demo" class="article_image" id="mp-demo-image">
<div class="admin__field field field-load_template " data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-form-field-load-template" style="">
<label class="label admin__field-label" for="banner_load_template" data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-note-banner-label"><span></span></label>
<div class="admin__field-control control">
<div id="banner_load_template" class="control-value admin__field-value" style=""><button id="id_lq27ZKqKzkY3i4p7JLoi57aNy7f2PDSk" title="Load Template" type="button" class="action-default scalable" data-ui-id="widget-button-0">
<span>Load Template</span>
</button>
</div>
</div>
</div>
if I will update default_template value I want to change default_image src using jQuery
magento2 magento2.3
I want to change Image src using jquery in magento2,
So how can I get Imageurl in jQuery?
<field name="default_template">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">KtplBannerManagementModelConfigSourceTemplate</item>
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Demo template</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">select</item>
<item name="formElement" xsi:type="string">select</item>
<item name="dataScope" xsi:type="string">default_template</item>
<item name="component" xsi:type="string">Ktpl_BannerManagement/js/form/element/defaultTemplate</item>
</item>
</argument>
</field>
<field name="default_image">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">true</item>
<item name="formElement" xsi:type="string">input</item>
<item name="elementTmpl" xsi:type="string">Ktpl_BannerManagement/form/element/defaultTemplate</item>
</item>
</argument>
</field>
defaultTemplate.html
<img alt="demo" class="article_image" id="mp-demo-image">
<div class="admin__field field field-load_template " data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-form-field-load-template" style="">
<label class="label admin__field-label" for="banner_load_template" data-ui-id="ktpl-bannerslider-banner-edit-tab-banner-fieldset-element-note-banner-label"><span></span></label>
<div class="admin__field-control control">
<div id="banner_load_template" class="control-value admin__field-value" style=""><button id="id_lq27ZKqKzkY3i4p7JLoi57aNy7f2PDSk" title="Load Template" type="button" class="action-default scalable" data-ui-id="widget-button-0">
<span>Load Template</span>
</button>
</div>
</div>
</div>
if I will update default_template value I want to change default_image src using jQuery
magento2 magento2.3
magento2 magento2.3
edited Jun 17 at 6:25
Aasim Goriya
4,0432 gold badges15 silver badges47 bronze badges
4,0432 gold badges15 silver badges47 bronze badges
asked Jun 14 at 10:41
Rutvee SojitraRutvee Sojitra
2,4851 gold badge5 silver badges24 bronze badges
2,4851 gold badge5 silver badges24 bronze badges
2
Do you need it in .phtml file or seperate JS file ?
– Aasim Goriya
Jun 14 at 10:48
In custom js file @AasimGoriya
– Rutvee Sojitra
Jun 14 at 11:05
Please check my ans.
– Aasim Goriya
Jun 14 at 11:13
but i want it in admin ui form
– Rutvee Sojitra
Jun 14 at 11:18
do you have .phtml file for your admin form page ?
– Aasim Goriya
Jun 14 at 11:19
|
show 3 more comments
2
Do you need it in .phtml file or seperate JS file ?
– Aasim Goriya
Jun 14 at 10:48
In custom js file @AasimGoriya
– Rutvee Sojitra
Jun 14 at 11:05
Please check my ans.
– Aasim Goriya
Jun 14 at 11:13
but i want it in admin ui form
– Rutvee Sojitra
Jun 14 at 11:18
do you have .phtml file for your admin form page ?
– Aasim Goriya
Jun 14 at 11:19
2
2
Do you need it in .phtml file or seperate JS file ?
– Aasim Goriya
Jun 14 at 10:48
Do you need it in .phtml file or seperate JS file ?
– Aasim Goriya
Jun 14 at 10:48
In custom js file @AasimGoriya
– Rutvee Sojitra
Jun 14 at 11:05
In custom js file @AasimGoriya
– Rutvee Sojitra
Jun 14 at 11:05
Please check my ans.
– Aasim Goriya
Jun 14 at 11:13
Please check my ans.
– Aasim Goriya
Jun 14 at 11:13
but i want it in admin ui form
– Rutvee Sojitra
Jun 14 at 11:18
but i want it in admin ui form
– Rutvee Sojitra
Jun 14 at 11:18
do you have .phtml file for your admin form page ?
– Aasim Goriya
Jun 14 at 11:19
do you have .phtml file for your admin form page ?
– Aasim Goriya
Jun 14 at 11:19
|
show 3 more comments
1 Answer
1
active
oldest
votes
You can add JS following way in your .phtml file
<script type="text/x-magento-init">
"*":
"Vendor_Module/js/custom-js":
"imageURL": "<?= $imageUrl; ?>"
</script>
Now in your custom JS file you can get your Image URL using following way.
So in Vendor_Module/web/js/custom-js.js file your JS code look like below.
define([
"jquery"
], function($)
"use strict";
function customFunction(config, element)
var imgURL = config.imageURL; //config.imageURL is already defined in your .phtml file
;
return customFunction;
);
add a comment
|
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/4.0/"u003ecc by-sa 4.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%2f278377%2fhow-to-get-imageurl-using-jquery-in-magento2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can add JS following way in your .phtml file
<script type="text/x-magento-init">
"*":
"Vendor_Module/js/custom-js":
"imageURL": "<?= $imageUrl; ?>"
</script>
Now in your custom JS file you can get your Image URL using following way.
So in Vendor_Module/web/js/custom-js.js file your JS code look like below.
define([
"jquery"
], function($)
"use strict";
function customFunction(config, element)
var imgURL = config.imageURL; //config.imageURL is already defined in your .phtml file
;
return customFunction;
);
add a comment
|
You can add JS following way in your .phtml file
<script type="text/x-magento-init">
"*":
"Vendor_Module/js/custom-js":
"imageURL": "<?= $imageUrl; ?>"
</script>
Now in your custom JS file you can get your Image URL using following way.
So in Vendor_Module/web/js/custom-js.js file your JS code look like below.
define([
"jquery"
], function($)
"use strict";
function customFunction(config, element)
var imgURL = config.imageURL; //config.imageURL is already defined in your .phtml file
;
return customFunction;
);
add a comment
|
You can add JS following way in your .phtml file
<script type="text/x-magento-init">
"*":
"Vendor_Module/js/custom-js":
"imageURL": "<?= $imageUrl; ?>"
</script>
Now in your custom JS file you can get your Image URL using following way.
So in Vendor_Module/web/js/custom-js.js file your JS code look like below.
define([
"jquery"
], function($)
"use strict";
function customFunction(config, element)
var imgURL = config.imageURL; //config.imageURL is already defined in your .phtml file
;
return customFunction;
);
You can add JS following way in your .phtml file
<script type="text/x-magento-init">
"*":
"Vendor_Module/js/custom-js":
"imageURL": "<?= $imageUrl; ?>"
</script>
Now in your custom JS file you can get your Image URL using following way.
So in Vendor_Module/web/js/custom-js.js file your JS code look like below.
define([
"jquery"
], function($)
"use strict";
function customFunction(config, element)
var imgURL = config.imageURL; //config.imageURL is already defined in your .phtml file
;
return customFunction;
);
edited Jun 17 at 5:10
answered Jun 14 at 11:13
Aasim GoriyaAasim Goriya
4,0432 gold badges15 silver badges47 bronze badges
4,0432 gold badges15 silver badges47 bronze badges
add a comment
|
add a comment
|
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%2f278377%2fhow-to-get-imageurl-using-jquery-in-magento2%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
2
Do you need it in .phtml file or seperate JS file ?
– Aasim Goriya
Jun 14 at 10:48
In custom js file @AasimGoriya
– Rutvee Sojitra
Jun 14 at 11:05
Please check my ans.
– Aasim Goriya
Jun 14 at 11:13
but i want it in admin ui form
– Rutvee Sojitra
Jun 14 at 11:18
do you have .phtml file for your admin form page ?
– Aasim Goriya
Jun 14 at 11:19