Created
June 23, 2012 23:47
-
-
Save bryanbibat/2980587 to your computer and use it in GitHub Desktop.
Replaces the title and all images with class="retina" in a WP blog that uses Pagelines theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//logic shamelessly copied from https://github.com/imulus/retinajs | |
jQuery(document).ready(function() { | |
var replaceRetina = function(elem) { | |
if (elem.complete) { | |
var src = elem.src; | |
var path_segments = src.split('.'); | |
var path_without_extension = path_segments.slice(0, (path_segments.length - 1)).join("."); | |
var extension = path_segments[path_segments.length - 1]; | |
elem.setAttribute('width', elem.offsetWidth); | |
elem.setAttribute('height', elem.offsetHeight); | |
elem.setAttribute('src', path_without_extension + "@2x." + extension); | |
} else { | |
setTimeout(function() { replaceRetina(elem) }, 5); | |
} | |
} | |
if (window.devicePixelRatio > 1) { | |
jQuery(".mainlogo-img, .retina").each(function(i) { | |
replaceRetina(this); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment