Insert variable in image CRS

Asked

Viewed 2,005 times

-1

How do I do that?

I need a "Variable" to be on the SRC tag img, and it will pull the images.

$JQuery('<div class="bannersucesso" style=" text-align: center;"><img src="#"></div>').insertBefore('.header-container');

In that src="#" there, it needs to stay this:

{{widget type="banner/widget_banner" template="banner/banner.phtml" banner="confimacao"}}

Only he doesn’t pull the image. How can I fix this?

  • What kind of platform are you using? And why can’t the src attribute only get the image path?

  • It is Magento, only it is a well modified Magento, Bizcommerce, and can not stay only the URL put that widget there pulls 2 images in case, pro PC and pro responsive.

1 answer

-1

Try this

First you should give an ID for your IMG tag.

Example:

Code:

<img src="" id="minhaImagem">

Now within your javascript code you can dynamically change the SRC attribute.

Code:

<script> 
document.getElementById("minhaImagem").src = [URL_DA_IMAGEM] 
</script> 

Substitute [URL_DA_IMAGEM] by the variable with the image path.

  • Thanks for the reply Michael, but keeps giving error: Uncaught Syntaxerror: Unexpected token {

Browser other questions tagged

You are not signed in. Login or sign up in order to post.