• Resolved gekomees

    (@gekomees)


    I have a problem with rendering avif files in a wordpress installation running in a subfolder with the subfolder being in the url.

    The Utilty:attachmentUrlToPath function calls ABSPATH but the parsed url path also has the subfolder name in it.

    Example: test.domain.com/sitefolder becomes media/htdocs/sitefolder/sitefolder/pathtoimage

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Pijush Gupta

    (@pijush_gupta)

    Hi @gekomees ,

    Please update the method with following code or download the latest development version from github: https://github.com/Pijushgupta/avif-express,


    public static function attachmentUrlToPath(string $url)

    {

    // Parse the URL to get the path

    $parsed_url = parse_url($url);

    if (empty($parsed_url['path'])) return false;

    // Get the upload directory data

    $upload_dir = wp_upload_dir();

    $upload_baseurl = $upload_dir['baseurl'];

    $upload_basedir = $upload_dir['basedir'];

    // Remove the base URL part to get the relative path

    $relative_path = str_replace($upload_baseurl, '', $url);

    $file_path = $upload_basedir . $relative_path;

    // Check if the file exists

    if (file_exists($file_path)) {

    return $file_path;

    }

    return false;

    }
    Thread Starter gekomees

    (@gekomees)

    Thank you. It works now!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.