Latest versions of PHP get mad if you try to reference array parameters that don’t exist. It’s a ‘warning’ type error, so the page will still load.
You need to test for existence of an array parameter before you reference it. So instead of
$attr['srcset'] = str_replace( array( '.jpeg' ), '.jpeg.webp', $attr['srcset'] );
Put those array references in an IF statement
if (isset($attr['srcset']) {
$attr['srcset'] = str_replace( array( '.jpeg' ), '.jpeg.webp', $attr['srcset'] );
}
That will eliminate that warning message. You will have to do similar to all array elements that may not exist.
You also do something like this:
$attr['srcset'] = ($attr['srcset']) ? str_replace( array( '.jpeg' ), '.jpeg.webp', $attr['srcset'] ) : "";
Which will set that array element to blank if it doesn’t exist, so you won’t have to test for it the next time you use it.
Related Posts:
- Core error when calling remove_menu_page
- WP_DEBUG is not set, but I’m still getting warnings
- Object of class WP_Error could not be converted to string
- Getting Warnings & Notices from Fresh WordPress 3.1.2 install
- Removing warnings and notices from production servers
- Handle new created WP_Error
- How do iterate through all errors for a WP_Error object?
- Getting notices on fresh 3.6.1 install
- Website Warning: call_user_func_array() expects parameter 1 to be a valid callback, class ‘Wppr_Public’ does not have a method ‘amp_support’
- Warning: spl_autoload() [function.spl-autoload] (Term Menu Order)
- Warning: call_user_func_array() [function.call-user-func-array]
- warnings & errors after MAMP to live (hosteurope)
- Lots of warnings and errors instead of my WordPress site – Synology NAS – Intranet
- How do I turn off WordPress errors and just have regular old php errors?
- Unable to locate WordPress Content directory (wp-content)
- How to fix “There has been a critical error on your website. Please check your site admin email inbox for instructions”?
- Notice: Use of undefined constant SCRIPT_DEBUG
- WordPress Redirecting to wp-admin/install.php
- When does remove_filter not work?
- How to display error messages using WP_Error class?
- Error 310 too many redirects after switching domains
- How do I set up Debugging?
- Error Logs to Diagnose Error 500 in LAMP
- Does wordpress have an error log?
- WP_DISABLE_FATAL_ERROR_HANDLER vs WP_DEBUG ? What to use and when to use to see errors?
- Call to undefined function get_header() in index.php
- Dashboard Whitescreen of Death?
- Why is_wp_error() is not returning false even there’s no defined error
- Unexpected Output: register_activation_hook with namespace
- WP Site Only Shows Javascript for Main Page
- PHP notice coming from the WordPress core?
- Get notified by email when Fatal error occurs on wordpress site?
- Get PHP Fatal error on globalized $wpdb: Call to a member function insert() on a non-object- I have no clue. What to do?
- media_buttons_context is deprecated
- PHP Fatal error: Call to a member function get() on null in /wp-includes/cache.php on line 123
- Unable To Login With Correct Credentials?
- Any way to check the integrity of a WordPress site?
- is_wp_error() and handling errors
- I am getting an error some times when uploading themes
- After upgrading Debian Buster to Bullseye, WordPress sites no longer updating
- My wordpress site loads perfectly, but I cannot access the menus in the admin panel
- Call to undefined function wp_embed_register_handler()
- Site works fine, but editing page causes error “Call to undefined function _wp_array_get()” in Gutenberg
- Odd error on top of my dashboard. How do I fix it?
- Deprecated issue in WordPress [closed]
- Why getting “The input type is invalid” when accessing edit.php?
- Warning: An unexpected error occurred. Something may be wrong with WordPress.org
- Visual editor not working after update
- Two Domain pointing to the same WordPress installation
- Front end empty (i.e. nothing displays); Back end looks fine; What are possible causes?
- Debugging: How to determine which plugin is throwing error in plugin.php
- “load-scripts.php” hangs and times out when plupload is requested
- How to trace an Error when it says nothing about any plugin?
- White Screen on Site but wp-admin OK
- Dummy data error
- require_once() error after moving WordPressto another server
- Internet Explorer cannot display the webpage
- Parse error:syntax error [closed]
- Why do these errors appear on my wordpress site? [closed]
- W3 Total Cache “Preview mode could not be disabled” [closed]
- Problem with UTF8. italian/russian characters
- Internal Server Error only on frontend and certain admin pages
- How to automatically convert “%” and “+” in image urls on upload
- Resolving a 500 Error with GoDaddy Hosting? [closed]
- Error: Attempt to read property “ID” on null
- Fatal error: Uncaught Error: Call to undefined function wp() in /home/nr4dxonhypyy/public_html/wp-blog-header.php:16
- A critical error has occurred on the site
- Why I get a blank screen when trying to make wordpress post/pages edits?
- Unable to edit with Elementor
- Getting Download failed. cURL error 28: Connection timed out after 10001 milliseconds
- WP_Fatal_Error_Handler OR WP_Error OR try/catch
- Fatal Error: Uncaught Error: call to undefined function get_plugin_data after uploading 2 blog posts(wp-shopify)
- WordPress error when update to new version
- Undefined index when saved to options
- The TypeError: this.each when wp.media.open() after using popper.js for bootstrap 4
- Parse error: syntax error, unexpected ”tax_query” in wordpress
- Can too-large images cause Error Establishing a Database Connection
- 403 error with no reason
- Error messages generated in ‘Customize Your Site’
- All of my wordpress sites showing †Ù¥
- How to find which plugin crashes
- Undefined Index. But isset not working?
- Possible to hide the search engine indexing disabled prompt/error message?
- Logging out gives 404 error
- Internal 500 error: Activating rootio theme and deploying with capistrano
- WordPress Error Missing Argument [duplicate]
- White background, black text – the simplest on earth : “error”!
- Twenty Eleven theme-options error
- Post show up as post and pages
- Random HTTP 500 error in WordPress
- I’m getting Call to undefined function wp_parse_list() out of the blue
- Add clickable function in functions.php – parse error [closed]
- Trying to add function with pre_get_posts for plugin search [closed]
- What are some best practices to clean up http mix content warnings?
- Fatal error due to file permissions
- Language of errors in WordPress admin
- index page is not loading [closed]
- Fatal error trace not shown in development setup
- syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW) [closed]
- Error code 499 on specific cron job