Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function to reverse the order in the WP srcset array
function reverse_srcset_order($atts) {
if (isset($atts['srcset'])) {
$srcset = explode(', ', $atts['srcset']);
$srcset_reversed = array_reverse($srcset);
$atts['srcset'] = join(', ', $srcset_reversed);
return $atts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment