close
Skip to content

Critical error when setting Featured Image #74

@RobinEd

Description

@RobinEd

When saving after having selected a Featured Image, the following error appears in a black box at the bottom:

There has been a critical error on this website. Learn more about troubleshooting WordPress.

Root cause

The REST save endpoint (press_this_rest_save_post) calls side_load_images(), which internally uses media_sideload_image() from wp-admin/includes/media.php. REST API requests do not load wp-admin/includes/ files by default, so this call results in a PHP fatal error: "Call to undefined function media_sideload_image()".

The error surfaces when the post content contains <img> tags with external URLs (e.g. scraped images inserted via the media panel). The sideload endpoint already includes these admin files, but the save endpoint was missing them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions