{"id":12238587,"date":"2019-12-14T15:53:09","date_gmt":"2019-12-14T15:53:09","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/not-all-sizes-appearing-in-srcset\/"},"modified":"2019-12-14T16:03:00","modified_gmt":"2019-12-14T16:03:00","slug":"not-all-sizes-appearing-in-srcset","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/not-all-sizes-appearing-in-srcset\/","title":{"rendered":"Not all sizes appearing in &#8220;srcset&#8221;"},"content":{"rendered":"<p>In my theme, I register the following image sizes:<\/p>\n<pre><code>add_image_size( &#039;256-horizontal&#039;, 256, 0 );\nadd_image_size( &#039;960-horizontal&#039;, 960, 0 );\nadd_image_size( &#039;1366-horizontal&#039;, 1366, 0 );\nadd_image_size( &#039;1920-horizontal&#039;, 1920, 0 );\nadd_image_size( &#039;4096-horizontal&#039;, 4096, 0 ); \/\/ This one won&#039;t generate here because it&#039;s larger than the original, that&#039;s not the issue.<\/code><\/pre>\n<p>However, when displaying the image on a page &#8211; wither inside a post, or as an attachment, certain sizes are not even written out into the <em>srcset<\/em>:<\/p>\n<pre><code>http:\/\/localhost\/wordpress\/wp-content\/uploads\/test.jpg 2528w,\nhttp:\/\/localhost\/wordpress\/wp-content\/uploads\/test-256x350.jpg 256w,\nhttp:\/\/localhost\/wordpress\/wp-content\/uploads\/test-960x1312.jpg 960w,\nhttp:\/\/localhost\/wordpress\/wp-content\/uploads\/test-1366x1867.jpg 1366w<\/code><\/pre>\n<p>As you can see, the 1920w size is not there. It has been generated &#8211; I&#8217;ve checked &#8211; but whatever loop is supposed to print it just doesn&#8217;t do it. (For this test I have disabled the default WordPress thumbnail sizes by setting the sizes of all 4 types to 0 x 0).<\/p>\n<p>I have checked that all image sizes are generated &#8211; the files are there, and they are also accessible via browser:<\/p>\n<pre><code>    Directory: C:\\xampp\\htdocs\\wordpress\\wp-content\\uploads\n\nMode                LastWriteTime     Length Name\n----                -------------     ------ ----\nd----        13\/12\/2019     10:03            temp\n-a---        14\/12\/2019     17:19     562892 test-1366x1867.jpg\n-a---        14\/12\/2019     17:19     975611 test-1920x2625.jpg\n-a---        14\/12\/2019     17:19      25697 test-256x350.jpg\n-a---        14\/12\/2019     17:19     308656 test-960x1312.jpg\n-a---        14\/12\/2019     17:19    2510193 test.jpg<\/code><\/pre>\n<p>The sizes are also registerred in the MySQL database, for what it&#8217;s worth (formatted for readability):<\/p>\n<pre><code>a:5:{\n  s:5:&quot;width&quot;;i:2528;s:6:&quot;height&quot;;i:3456;s:4:&quot;file&quot;;s:8:&quot;test.jpg&quot;;s:5:&quot;sizes&quot;;\n  a:4:{\n    s:14:&quot;256-horizontal&quot;;a:4:{s:4:&quot;file&quot;;s:16:&quot;test-256x350.jpg&quot;;s:5:&quot;width&quot;;i:256;s:6:&quot;height&quot;;i:350;s:9:&quot;mime-type&quot;;s:10:&quot;image\/jpeg&quot;;}\n    s:14:&quot;960-horizontal&quot;;a:4:{s:4:&quot;file&quot;;s:17:&quot;test-960x1312.jpg&quot;;s:5:&quot;width&quot;;i:960;s:6:&quot;height&quot;;i:1312;s:9:&quot;mime-type&quot;;s:10:&quot;image\/jpeg&quot;;}\n    s:15:&quot;1366-horizontal&quot;;a:4:{s:4:&quot;file&quot;;s:18:&quot;test-1366x1867.jpg&quot;;s:5:&quot;width&quot;;i:1366;s:6:&quot;height&quot;;i:1867;s:9:&quot;mime-type&quot;;s:10:&quot;image\/jpeg&quot;;}\n    s:15:&quot;1920-horizontal&quot;;a:4:{s:4:&quot;file&quot;;s:18:&quot;test-1920x2625.jpg&quot;;s:5:&quot;width&quot;;i:1920;s:6:&quot;height&quot;;i:2625;s:9:&quot;mime-type&quot;;s:10:&quot;image\/jpeg&quot;;}\n  }\n  s:10:&quot;image_meta&quot;;a:12:{...other metadata...}\n}<\/code><\/pre>\n<p>I have experimented with a bunch of sizes, and I&#8217;m not sure if it has to do with image size (shouldn&#8217;t, I&#8217;ve seen it print larger images before, but in my current case it doesn&#8217;t seem to go above 1650 in some cases, or above 1600 in others*), or maybe the amount of sizes (I tried adding only the 1920 size, but it still didn&#8217;t print into the <em>srcset<\/em>). Finally, I tried this with a bunch of different themes just in case, to no avail either.<\/p>\n<p>*The only response I got was with changing sizes, but even that seemed inconclusive. In one test, it seemed to stop adding sizes to the list above 1650 (when I created sizes 1600, 1610, 1620 &#8230; 1650), but after coming back and trying it again, the largest size it prints is 1600w.<\/p>\n<p>I&#8217;m quite stumped. Any ideas?<\/p>\n<p>PS: The WordPress instance is a clean install with no plugins (default ones disabled) and version 5.2.5, with themes tested: TwentyNineteen, Underscores, Susty<\/p>\n","protected":false},"template":"","class_list":["post-12238587","topic","type-topic","status-publish","hentry","topic-tag-images","topic-tag-srcset","topic-tag-themes"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12238587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":2,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12238587\/revisions"}],"predecessor-version":[{"id":12238623,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12238587\/revisions\/12238623"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12238587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}