{"id":6211,"date":"2017-01-04T13:08:21","date_gmt":"2017-01-04T13:08:21","guid":{"rendered":"http:\/\/dev.adambowie.com\/?p=6211"},"modified":"2017-01-04T13:40:14","modified_gmt":"2017-01-04T13:40:14","slug":"image-posting-test","status":"publish","type":"post","link":"https:\/\/dev.adambowie.com\/blog\/2017\/01\/image-posting-test\/","title":{"rendered":"Image Posting &#8211; A Bit More Optimised"},"content":{"rendered":"<p><a href=\"http:\/\/dev.adambowie.com\/2017\/01\/failing-to-optimise-this-site\">Yesterday<\/a> I mentioned that I was struggling with embedding properly responsive images that will go lovely and large if you have a nice big screen, but only download a small image if that&#8217;s all I need. Added to which, I use Flickr to host all my images for me.<\/p>\n<p><a href=\"http:\/\/dev.adambowie.com\/2017\/01\/failing-to-optimise-this-site\/#comment-4502\">Thanks to Emily in the comments<\/a> for alerting me to <code>srcset<\/code> as being the way to do this properly.<\/p>\n<p>While it doesn&#8217;t look like there&#8217;s a handy WordPress Flickr-embedder that will do this easily, you can spend a bit of time getting details of the URLs of each sized image, and put together some code that does the trick. <\/p>\n<p>Here&#8217;s an example. If you&#8217;re looking at this on a mobile phone, you might only be seeing the 320px image. But on a lovely large or retina display, you may be seeing a 2048px image!<\/p>\n<p>(At least I hope that&#8217;s the case)<\/p>\n<p><a href=\"https:\/\/www.flickr.com\/photos\/adambowie\/31836754726\/\" title=\"Across the rooftops at dawn\"><img decoding=\"async\" src=\"https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_n_d.jpg\" srcset=\"https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_z_d.jpg 640w, https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_c_d.jpg 800w, https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_b_d.jpg 1024w, \nhttps:\/\/c1.staticflickr.com\/1\/427\/31836754726_d378ecf063_h_d.jpg 1600w, https:\/\/c1.staticflickr.com\/1\/427\/31836754726_f37b9c6b4a_k_d.jpg 2048w\" alt=\"Across the rooftops at dawn\"><\/a><\/p>\n<p>Here&#8217;s the code I used to do this:<\/p>\n<blockquote><p><code>&lt;a href=\"https:\/\/www.flickr.com\/photos\/adambowie\/31836754726\/\" title=\"Across the rooftops at dawn\"&gt;&lt;img src=\"https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_n_d.jpg\" srcset=\"https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_z_d.jpg 640w, https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_c_d.jpg 800w, https:\/\/c1.staticflickr.com\/1\/427\/31836754726_cbbe667b3e_b_d.jpg 1024w,<br \/>\nhttps:\/\/c1.staticflickr.com\/1\/427\/31836754726_d378ecf063_h_d.jpg 1600w, https:\/\/c1.staticflickr.com\/1\/427\/31836754726_f37b9c6b4a_k_d.jpg 2048w\" alt=\"Across the rooftops at dawn\"&gt;&lt;\/a&gt;<\/code><\/p><\/blockquote>\n<p>Essentially, the first image, <code>31836754726_cbbe667b3e_n_d.jpg<\/code> in my case, is the 320px image on Flickr. Then inside <code>srcset<\/code> are <em>some<\/em> of the other different sizes available. I probably could reduce this list a little, since you do need to get the precise Flickr URLs for each size from the download page for the photo.<\/p>\n<p>Still, I think this all works, and so despite being a little bit more of a hassle to embed a picture than previously, I&#8217;ll try to do something like this in the future. Then I&#8217;ll see if Google likes it! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday I mentioned that I was struggling with embedding properly responsive images that will go lovely and large if you have a nice big screen, but only download a small image if that&#8217;s all I need. Added to which, I use Flickr to host all my images for me. Thanks to Emily in the comments [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/posts\/6211"}],"collection":[{"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/comments?post=6211"}],"version-history":[{"count":4,"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/posts\/6211\/revisions"}],"predecessor-version":[{"id":6216,"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/posts\/6211\/revisions\/6216"}],"wp:attachment":[{"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/media?parent=6211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/categories?post=6211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.adambowie.com\/blog\/wp-json\/wp\/v2\/tags?post=6211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}