When directly viewing an image on Tumblr, ensures that the highest resolution image is loaded.
Actually, still need a fallback, if the raw does not exist or is inaccessible (shouldn't happen really, but just in case...)
var sizes = [ '_raw.', '_1280.', '_540.', '_500.', '_400.', '_250.', '_100.' ];
function checkSize(index) {
if (index >= sizes.length) return;
var url = "";
if (index <= 1) {
url = window.location.href.replace(/(https?:\/\/)\d+\.(.*(?=_))(_\d*.)(.*)/, '$1' + '$2' + sizes[index] + '$4');
}
else if (index > 1) {
url = window.location.href.replace(/\d+\.(.*(?=_))(_\d*.)(.*)/, '$1' + sizes[index] + '$3');
}
if (url == window.location.href) return;
etc...
I didn't even know a 'raw' version was available, thanks for the info. I've updated the script to prefer the 'raw' version.
Patch to improve to actual best quality here
I'm surprised you only go for the 1280p version of the files, which is NOT the "highest" resolution available.
Example: small: https://68.media.tumblr.com/##########/tumblr_orronwuFzC1umluozo5*_540.png better: https://68.media.tumblr.com/##########/tumblr_orronwuFzC1umluozo5_1280.png best if available: https://68.media.tumblr.com/##########/tumblr_orronwuFzC1umluozo5_raw.png best also and more likely: https://media.tumblr.com/##########/tumblr_orronwuFzC1umluozo5_raw*.png
Simply change the regexp as follows and it works:
var sizes = [ '_raw.', '_1280.', '_540.', '_500.', '_400.', '_250.', '_100.' ]; ... var url = window.location.href.replace(/(https?:\/\/)\d+\.(.*(?=_))(_\d*.)(.*)/, '$1' + '$2' + sizes[index] + '$4');
Please update accordingly?