Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save philbar/1dc88fcc0c89f3df55a5 to your computer and use it in GitHub Desktop.
Save philbar/1dc88fcc0c89f3df55a5 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
var getUrlParams = function() {
var params = {}, hash;
var hashes = decodeURI(window.location.href).replace(/\+/g," ").slice(window.location.href.indexOf('?') + 1).split('&');
for (var i=0; i<hashes.length; i++) {
hash = hashes[i].split('=');
params[hash[0]] = hash[1];
}
return params;
};
jQuery(function() {
// Add URL of image here. Make sure it is the same dimensions as the image you are replacing
var dynamicImage = "http://IMAGE-URL-GOES-HERE";
// Update "keyword" to match the parameter you chose.
var keyword = getUrlParams()['keyword'];
// Update "Keyword to be matched".
if (keyword == "KEYWORD TO BE MATCHED") {
// Update "#lp-pom-image-01" to match the div of the image you want changed
jQuery('#lp-pom-image-01 img').attr('src', dynamicImage)
}
});
</script>
@JasonCRoach
Copy link

Hello... I'm trying to implement this, but am not having any luck. I think I'm plugging the wrong information in to the wrong spot

@bmcintyre21
Copy link

I am having the image problems.

@bmcintyre21
Copy link

This does not work. Any help. And also with multiple images? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment