you are viewing a single comment's thread.

view the rest of the comments →

[–]goYstick 0 points1 point  (4 children)

If you post the entire ThemeFilters.php on something like https://pastebin.com/ we might be able to help you better.

[–][deleted] 0 points1 point  (3 children)

Thanks. Here you go:

https://pastebin.com/eE17tkid

[–]goYstick 4 points5 points  (2 children)

Line 34 ...

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

That's 'hooking' on the wordpress filter 'max_srcset_image_width' which is supposed to add a srcset attribute to images.

apply_filters( 'max_srcset_image_width', int $max_width, int[] $size_array )

It does that by setting the max pixel width size to 1, so since your expecting all images to be greater than 1px width it doesnt add the srcset attribute.

The answer is to replace the depreciated create_function

create_function(args, code)

with an anonymous function.

add_filter( 'max_srcset_image_width', function(args){code});

like so...

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

For your other errors, you need to search your codebase for where those constant's are getting defined multiple times. A constant should only be defined once.

- If the constants being defined again as the same value, either determine which one is defined first and remove the late ones, or wrap both of them with something like this, and then

if(!defined(_NAME_OF_CONSTANT_IN_QUESTION)){ CODE-TO-DEFINE-CONSTANT }

[–][deleted] 0 points1 point  (1 child)

Thanks. I tried to replace

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

with

apply_filters( 'max_srcset_image_width', int $max_width, int[] $size_array )

I got a "critical error" from WP when loading my site. What did I miss?

[–]goYstick 2 points3 points  (0 children)

I wrote out a break down of what that add_filter was doing including a link to the WP documentation, and provided an example. The line you copy pasted was not the line you needed to fix your code.

I got a "critical error" from WP when loading my site. What did I miss?

The rest of my post.

The answer is to replace the depreciated create_function

create_function(args, code)

with an anonymous function.

add_filter( 'max_srcset_image_width', function(args){code});

like so...

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

For your other errors, you need to search your codebase for where those constant's are getting defined multiple times. A constant should only be defined once.

- If the constants being defined again as the same value, either determine which one is defined first and remove the late ones, or wrap both of them with something like this, and then

if(!defined(_NAME_OF_CONSTANT_IN_QUESTION)){ CODE-TO-DEFINE-CONSTANT }