• We encountered PHP warnings when the plugin processes missing/404 images embedded in post content:

    PHP Warning: file_get_contents(https://example.com/images/missing.jpg):
    Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

    PHP Warning: exif_imagetype(https://example.com/wp-content/uploads/missing.gif):
    Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

    Issue: The saswp_get_image_details() function attempts to validate all images in content, including external or broken URLs, causing error log spam.

    Workaround: We added a filter to only process images from our uploads directory:

    add_filter('saswp_get_image_details', function($img_details, $url) {
    if ($img_details !== false) return $img_details;
    if (!filter_var($url, FILTER_VALIDATE_URL)) return false;

    $uploads_url = wp_upload_dir()['baseurl'];
    $uploads_normalized = preg_replace('#^https?://#', '', $uploads_url);
    $url_normalized = preg_replace('#^https?://#', '', $url);

    return (strpos($url_normalized, $uploads_normalized) === 0) ? false : [];
    }, 10, 2);

    Suggestion: Consider adding URL validation before calling file_get_contents() or gracefully handling 404 responses to prevent warnings on missing images.

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Support Akshay A

    (@akshaycode1)

    Hi,

    Thank you for sharing this. We have raised a GitHub ticket regarding this concern and it will be addressed in an upcoming update. We kindly request your patience in the meantime.

    Here is the GitHub Ticket.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.