Skip to content

[Bug]: Issue with realpath #3

@captenmasin

Description

@captenmasin

What happened?

I'm getting a 404 on a fresh installation with Spatie Media library when accessing an image transform URL

I'm sure it's something I've done wrong but I can't quite figure it out

How to reproduce the bug

I have an image stored at /storage/app/public/29/content.png
With the config set to 'public_path' => env('IMAGE_TRANSFORM_PUBLIC_PATH', 'storage'), as the comment suggests, however going to /image-transform/width=250,quality=80,format=webp,blur=50/29/content.png serves a 404

Diving into the package code and dd'ing
dd(public_path($pathPrefix.'/'.$path), $publicPath);

Gives me

"/Users/mason/Sites/library/public/storage/29/content.png"
"/Users/mason/Sites/library/storage/app/public/29/content.png"

But if I change the line
$publicPath = realpath(public_path($pathPrefix.'/'.$path));
into
$publicPath = public_path($pathPrefix.'/'.$path);

I get

"/Users/mason/Sites/library/public/storage/29/content.png"
"/Users/mason/Sites/library/public/storage/29/content.png"

and it works fine

Package Version

0.4.0

PHP Version

8.4.8

Laravel Version

12.19.3

Which operating systems does this happen with?

macOS

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions