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

generate() method is cutting off last part of image publicId #7

Open
minoesteban opened this issue Jul 7, 2022 · 1 comment
Open

Comments

@minoesteban
Copy link

minoesteban commented Jul 7, 2022

Hi everyone! We recently upgraded from 3.0.1+7 to 4.0.1+9 version of the package, and found a problem. Not sure if we are missing something new or is it really a bug

We can see now that the generate() method now removes the last part of an image's public id, if this id has any dots in it. Specifically, it removes the part after the last dot (like it is removing the file extension)

Thing is, public ids don't have extensions, so this does not have any effect, expect for file names with dots. Is this intentional? What is the purpose behind this new logic?

Thank you

@luis901101
Copy link
Owner

Hi, thanks for reporting this. I'll explain the situation.

The generate() function in CloudinaryTransformation is not the one that removes the last .xyz, it is the CloudinaryImage constructor the one that does that removal. This constructor receives a cloudinary resource url as parameter and extracts the public_id from it, in the process it removes as you noticed the last possible .ext if it has one; e.g: tempPublicId = tempPublicId.substring(0, lastDotIndex);. So far I have created only the CloudinaryImage class which will match the CloudinaryResourceType.image type from API. So according to official documentation:

The Public ID value for images and videos should not include a file extension. Include the file extension for raw files only.

That's why the CloudinaryImage constructor does the .ext removal from public_id when extracting it from url.

The current logic implemented in the last breaking change version ^4.0.0 is the same as ^3.0.0 regarding the .ext removal from public_id in the CloudinaryImage constructor.

If you are experiencing some problem while using image transformations with this logic, let me know to see how we can fix it.

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

No branches or pull requests

2 participants