Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets preview in the CMS is not working #5

Closed
valboivin opened this issue Dec 6, 2023 · 4 comments
Closed

Assets preview in the CMS is not working #5

valboivin opened this issue Dec 6, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@valboivin
Copy link

valboivin commented Dec 6, 2023

The asset delivery URL for my images is not the same on the deployed website versus in the CMS panel (i.e. for previews).

It seems like the URL generated for my images in the website is based on the Base URL I've entered in the config, which is good!
Images on the live websites work just fine.

However, the URL generated to preview images in the CMS or in the Assets pages of the admin is wrong. It points out to the default delivery URL for Cloudinary (https://res.cloudinary.com/...). It's not using the mentioned base URL from the settings in my filesystems. Since our account has its own private CDN distribution configurations, I think that the asset delivery URL should use our base url instead to work.

As seen on Cloudinary documentation:

screenshot 2023-12-06 at 4 45 35 PM

@thomasvantuycom
Copy link
Owner

Hi Valerie,

I've added support for custom CNAMEs in version 1.4.0. I am confident that the transformation URLs should now be accurate; however, please let me know if you come across any discrepancies.

@thomasvantuycom thomasvantuycom added the enhancement New feature or request label Dec 7, 2023
@valboivin
Copy link
Author

valboivin commented Dec 7, 2023

@thomasvantuycom thank you so much for this quick enhancement! 👍 😄

I still have one minor problem with the generated URL for the transformation to work.

In our Cloudinary setup, we do use the fixed folders structure. We have base folders for every environments we are using. I know there's a way for the Upload API to specify a folder name in the upload options, but I don't see any for the transformation.

Could I suggest some more enhancements to the plugin to support base folder? I've modified the code on my side to make it work. Here's what I suggest:

  • Adding a field in the plugin to specifiy the base folder name and make it a property of the CloudinaryFs class
        public string $baseFolder = '';
  • In the getTransformUrl function, prepend the publicId with this base folder value
        $hasBaseFolder = !(empty($fs->baseFolder));

        $publicId = $asset->getUrl();
        if ($isCloudinaryFs) {
            $publicId = $hasDynamicFolders ? basename($asset->getPath()) : $asset->getPath();
        }
        if($hasBaseFolder) {
            $publicId = '/'. $fs->baseFolder . '/' . $publicId;
        }

Let me know what you think!

@valboivin
Copy link
Author

valboivin commented Dec 7, 2023

I'm suggesting a Pull Request for the support of the base folder. (#6) Feel free to review it. Thank you!

@thomasvantuycom
Copy link
Owner

I've moved the second request to its own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants