codebar-ag / laravel-flysystem-cloudinary

Cloudinary Flysystem integration with Laravel.
https://www.cloudinary.com
MIT License
9 stars 5 forks source link

[Bug]: getUrl is requesting the API #48

Closed simonmilz closed 9 months ago

simonmilz commented 9 months ago

What happened?

I am using the Cloudinary Nova Field. After I added the CloudinaryImage Field to my resource the UI was getting really slow. While I was investigating for a while, I found out that https://github.com/codebar-ag/laravel-flysystem-cloudinary/blob/main/src/FlysystemCloudinaryAdapter.php#L523 is calling the API, instead of simply returning the public URL:

try {
    $response = $this->explicit($path);
} catch (NotFound) {
    return false;
}

IMO this would be enough and MUCH faster:

try {
    return (string) $this->cloudinary->image($path)->toUrl();
} catch (NotFound) {
     return false;
}

Package Version

3.1

PHP Version

8.2

Laravel Version

10.0

Which operating systems does with happen with?

No response

StanBarrows commented 9 months ago

Hey @simonmilz

Many thanks for the hint. We'll fix this within this week.

Best regards Sebastian

simonmilz commented 9 months ago

For the Nova Field you should consider to use the preview and thumbnail methods to generate smaller images: https://github.com/Silvanite/nova-field-cloudinary/blob/master/src-php/Fields/CloudinaryImage.php#L24

This would improve the field even more ;)

RhysLees commented 9 months ago

@simonmilz I made a pr #49 for this, feel free to take a look and let me know if it checks out for you

StanBarrows commented 9 months ago

@RhysLees thanks for the updating both packages.

@simonmilz

Please note that both versions are currently in alpha release. We await the Laravel 11 Release to mark both version bumps as stable. The stable release is expected in the first week of March.