Fix for #68. I did my best to add high-resolution image support in a way that a) didn't require huge changes to how the app works and b) minimizes requests to xkcd servers.
Unfortunately there is no way (that I could find) to determine the high-resolution image URL to use. Some comics use the default img
URL, some use the img
but with _large
at the end (those are usually the ones that the xkcd.com comic image is a link to a larger version), and almost every comic >= 1084 has a _2x
version (the only ones without _2x
are some of the ones that use _large
).
So my change will, on loading the image, attempt _large
, then attempt _2x
, then fall back to the default image URL. However, to minimize requests, I have hardcoded known comics that are _large
up to current date, so it doesn't have to check for the vast majority that aren't. This doesn't need to be updated -- future comics not included in the hardcoded part will just always check for _large
first. Sorry it's so ugly, but I'm not sure there's a better way to do it, since the xkcd API is so useless for high-res images.
Also comics 256 and 273 are special -- their default image URL has _small
at the end, but the link is to one with no suffix. I just hard-coded these URLs. It will still fall back to the default URL if my hard-coded URL fails.
Additionally, since the 2x comics are bigger, I modified the view controller to zoom out to 0.5 when loading comics >= 1084. That way, they don't show up super big on screen by default. (While doing this, I also fixed the "Open Zoomed Out" feature, which did not seem to be working originally.)