Suggested fix for incompatability with some plugins
-
Hi,
After upgrading to php 8.1, I’m seeing this error on some sites:
Fatal error: Uncaught TypeError: reset(): Argument #1 ($array) must be of type array, bool given in /site/wp-content/plugins/svg-support/functions/attachment.php:280
From what I can tell, this is caused by plugins preventing srcset functions to work. Returning false on the srcset filter was a way of disabling it completely.
I would suggest making a minor adjustment to the code to prevent a fatal error if in fact a bool is passed.
// remove srcset for svg images function bodhi_svgs_disable_srcset( $sources ) { if( !is_array( $sources ) ) { return $sources; } $first_element = reset($sources);
Thank you in advance.
- The topic ‘Suggested fix for incompatability with some plugins’ is closed to new replies.