Last active
February 18, 2017 10:13
-
-
Save Christian-Roth/fdc34dc88935087aa494 to your computer and use it in GitHub Desktop.
Function to reverse the order in the WP srcset array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
add_filter('wp_get_attachment_image_attributes','reverse_srcset_order',1,1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment