• Resolved tnoguchi

    (@tnoguchi)


    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 2 replies - 1 through 2 (of 2 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.

    Plugin Support Akshay A

    (@akshaycode1)

    Hi,

    Hope you are doing well.

    We have released version 1.56, in which this concern has been addressed. Kindly update the plugin to the latest version, clear the cache, and give it a try.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.