First of all: is it even possible?
I'd like to get a function that returns an srcset <img>
tag to make my wordpress layout responsive. This is important for me because my wrapper is 1400 wide, which is good for screens wider than 1400 @1 or 700 @2, but for mobile phones is too wide, and 720px width would be enough for @2 and even @3 screens (as they could get sharper but eye wouldn't notice too much).
The problem is I can't know which thumbnail size to serve while processing the php... so I'd like to use a srcset
. To do that I know I must write something on the functions.php
. But what should I do and how? Should I modify the_post_thumbnail()
function? Or should I create a new one? In that case, how can I get the different image names from the different sizes of the post thumbnail?