• Resolved nullport

    (@nullport)


    With lazysizes enabled, I’m getting the following PHP error being displayed. This is replicatable from WordPress 4.9.x running PHP 7.2 and also on the current WordPress 5.4.2 running php 7.4.7

    I have redacted the web dir path but the error is as follows. Let me know if you need any more detail.

    When lazysizes is disabled, then this error message does not appear.

    I am using the latest version lazysizes 1.2.1 however I also got it with version 1.1.0

     Warning: preg_replace(): Unknown modifier '/' in [redacted web dir]/wp-content/plugins/lazysizes/inc/Lazysizes/class-pregreplace.php on line 329
    Call Stack
    #	Time	Memory	Function	Location
    1	0.0001	367160	{main}( )	.../index.php:0
    2	0.0001	367440	require( '[redacted web dir]/wp-blog-header.php' )	.../index.php:17
    3	0.7395	24524136	require_once( '[redacted web dir]/wp-includes/template-loader.php' )	.../wp-blog-header.php:19
    4	0.7444	24561544	include( '[redacted web dir]/wp-content/themes/[redacted theme name]/page-new.php' )	.../template-loader.php:106
    5	1.9940	25895160	get_template_part( )	.../page-new.php:19
    6	1.9940	25895680	locate_template( )	.../general-template.php:168
    7	1.9940	25895792	load_template( )	.../template.php:672
    8	1.9941	25896048	require( '[redacted web dir]/wp-content/themes/[redacted theme name]/content-page.php' )	.../template.php:725
    9	1.9944	25896048	the_content( )	.../content-page.php:3
    10	1.9946	25896048	apply_filters( )	.../post-template.php:253
    11	1.9946	25896456	WP_Hook->apply_filters( )	.../plugin.php:206
    12	2.7277	47488680	Lazysizes\PluginCore->filter_html( )	.../class-wp-hook.php:287
    13	2.7277	47488680	Lazysizes\PregReplace->preg_replace_html( )	.../class-plugincore.php:298
    14	2.7277	47488680	Lazysizes\PregReplace->replace_generic_tag( )	.../class-pregreplace.php:66
    15	2.7281	47515888	Lazysizes\PregReplace->get_replace_markup( )	.../class-pregreplace.php:173
    16	2.7281	47516424	Lazysizes\PregReplace->add_lazyload_class( )	.../class-pregreplace.php:199
    17	2.7281	47516776	preg_replace ( )	.../class-pregreplace.php:329
    • This topic was modified 4 years, 4 months ago by nullport.
    • This topic was modified 4 years, 4 months ago by nullport.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Patrick Sletvold

    (@16patsle)

    Thanks for the report, I will look into this and report back as soon as possible.

    Best regards,
    Patrick Sletvold

    Plugin Author Patrick Sletvold

    (@16patsle)

    Hello @nullport,

    The error occurs because the class attribute of the element being lazyloaded contains a slash, which the plugin previously didn’t expect. This is already fixed as part of another recent change, but isn’t in a published version of the plugin yet.

    I’m currently working on the next version of the plugin, which should release pretty soon. In the mean time, if removing the slash from the class attribute is an option and something you know how to do, that would also work. As far as I am aware, it isn’t considered valid HTML anyways, even though it works in other instances. Otherwise, the next version should fix the problem when released.

    Best regards,
    Patrick Sletvold

    Thread Starter nullport

    (@nullport)

    Thanks so much for your work! I will check it out in 1.3.2. Best.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘lazysizes creates preg_replace PHP Error’ is closed to new replies.