{"id":77,"date":"2007-07-30T02:55:05","date_gmt":"2007-07-30T06:55:05","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/2007\/07\/30\/an-image-idea\/"},"modified":"2007-07-30T02:55:05","modified_gmt":"2007-07-30T06:55:05","slug":"an-image-idea","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/07\/30\/an-image-idea\/","title":{"rendered":"An Image Idea"},"content":{"rendered":"<p>Some of my favorite posts are the ones with images. I like to sometimes post photos I take, and they can really make a post much better. (As an example, Kyle&#8217;s recent headphones post.)<\/p>\n<p>There are some &#8216;risks&#8217; with allowing images, though:<\/p>\n<ul>\n    <li>Offsite images can change. You might post a little picture you found somewhere, and have the image on that server be replaced by a 1600&#215;1200 porn image. Or an advertisement. Etc. Not a big deal with the way people are using them now, really.<\/li>\n    <li>Offsite images can slow the page down. Lately I&#8217;ve been working on benchmarking the site a lot, trying to get pages to load quickly. I can&#8217;t optimize the load times of images that aren&#8217;t on my server, though.<\/li>\n    <li>Offsite images can be used for tracking. The remote site gets the IP, and lots of other information, of the visiting site. This is probably a non-issue here, but images can be, and are, used for tracking purposes all the time.<\/li>\n    <li>I can&#8217;t really &#8216;regulate&#8217; images: You could post a dozen 1600&#215;1200 images as uncompressed TIFFs, and there&#8217;s nothing I can do about it. (Well, I could, and would, edit your post&#8230;)<\/li>\n<\/ul>\n<p>It just occurred to me, though, that I could theoretically write some code to work around these issues, such as by doing the following:<\/p>\n<ul>\n    <li>Get the text from the database to display. (This is, of course, what happens so far.)<\/li>\n    <li>Scan the text for image tags.<\/li>\n    <li>If an image tag is found, see if we have the image cached already:\n<ul>\n    <li>If so, we just change the image tag to point to our local cache instead.<\/li>\n    <li>If not, the server can go and download the image into its cache.\n<ul>\n    <li>It can then &#8216;process&#8217; it as needed, such as scaling it down and making sure it&#8217;s not an animated GIF.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>An even better extension of this idea would be to enclose the image tag in links to the full original. (Although this falls apart if the image is already linked.)<\/p>\n<p>I guess there are a few issues (besides taking the time to implement it):<\/p>\n<ul>\n    <li>There may be legal issues, as I&#8217;m essentially saving and redisplaying someone else&#8217;s images. I don&#8217;t think this would really be a big deal.<\/li>\n    <li>The post-processing can&#8217;t look like crap. I have no idea what to expect.<\/li>\n    <li>It would raise the server&#8217;s bandwidth usage. If someone links to a bunch of images, the bandwidth comes from that server. When they&#8217;re hosted here, it&#8217;s my bandwidth. But since I&#8217;ve been coming about 999 GB short of hitting my 1,000 GB limit, this isn&#8217;t a big issue right now. (Also, half the goal is to reduce the size of the images, so the impact wouldn&#8217;t be as big.) In extreme cases, it would also increase resource usage: normally serving up a couple small images is peanuts, but if the site were to be hammered with traffic, it&#8217;d slow things down somewhat.<\/li>\n    <li>We need to somehow limit the size of the cache. This can be done simply, by just setting a limit on how large the cache can grow and deleting the oldest images when it exceeds that size. This isn&#8217;t a perfect solution, though; for example, it has the implicit assumption that newer images are more important to cache. This is probably accurate more often than not, but it&#8217;s not always the case. (Example: an old post with images is linked to from other sites, or comes up a lot in searches.)<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Some of my favorite posts are the ones with images. I like to sometimes post photos I take, and they can really make a post much better. (As an example, Kyle&#8217;s recent headphones post.) There are some &#8216;risks&#8217; with allowing &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/07\/30\/an-image-idea\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-computers"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}