]*)(href|src|action)=[\"'])https?:\\/\\//i"; $subst = '$1//'; $return = preg_replace( $re, $subst, $buffer ); if ( $return ) { $buffer = $return; } return $buffer; } /** * Remove HTTP protocol on srcset attribute generated by WordPress * * @since 2.7 * * @param array $sources an Array of images sources for srcset. * @return array Updated array of images sources */ function rocket_protocol_rewrite_srcset( $sources ) { if ( (bool) $sources ) { foreach ( $sources as $i => $source ) { $sources[ $i ]['url'] = str_replace( [ 'http:', 'https:' ], '', $source['url'] ); } } return $sources; }