1

I have recently upgraded a site im working on from PHP Version 5.6 to 7.3

The problem I am having is with a deprecated function in my wordpress functions.php

add_filter('max_srcset_image_width', create_function('', 'return 1;'));

How would i rewrite the above code for 7.3

I have already tried:

add_filter('max_srcset_image_width', function('', 'return 1;'));

Thanks

HizY
  • 49
  • 7

1 Answers1

2

You can use functions directly like closures.

add_filter('max_srcset_image_width', function() { return 1; });

Update:

Since PHP 7.4 you can use shorthand arrow functions and write it shorter.

add_filter('max_srcset_image_width', fn() => 1);
Markus Zeller
  • 8,516
  • 2
  • 29
  • 35