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;









5

















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










share|improve this question























  • 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

















5

















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










share|improve this question























  • 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













5












5








5








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










share|improve this question

















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






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








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












  • 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










1 Answer
1






active

oldest

votes


















6


















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;
);





share|improve this answer





























    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
    );



    );














    draft saved

    draft discarded
















    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









    6


















    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;
    );





    share|improve this answer
































      6


















      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;
      );





      share|improve this answer






























        6














        6










        6









        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;
        );





        share|improve this answer
















        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;
        );






        share|improve this answer















        share|improve this answer




        share|improve this answer








        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































            draft saved

            draft discarded















































            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.




            draft saved


            draft discarded














            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





















































            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









            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?