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

Cloudinary SEO Suffix #17

Open
colbyfayock opened this issue Feb 27, 2023 · 2 comments
Open

Cloudinary SEO Suffix #17

colbyfayock opened this issue Feb 27, 2023 · 2 comments

Comments

@colbyfayock
Copy link

Cloudinary has support for something called an SEO suffix. The idea is, you can customize the end of your image URL where the public ID would normally be, to add something SEO friendly.

Think instead of something like .../image/upload/oaisnd143, you can do .../images/oaisnd143/cool-image-with-stuff

I just added support for it in my little tool: cloudinary-community/cloudinary-util#19

Here's the updated regex:

https://github.com/colbyfayock/cloudinary-util/blob/main/packages/util/src/lib/cloudinary.ts#L2

HOWEVER

my regex requires a version in the URL so make parsing more predictible which I dont think yours is currently doing. Might be able to still get away with it, but regex isn't my thing, which is why I'm not putting in a PR instead of this 🙈

Relevant docs: https://cloudinary.com/documentation/advanced_url_delivery_options#seo_friendly_media_asset_urls

@colbyfayock
Copy link
Author

Oh and if it helps, heres a regex101 that helped me visualize: https://regex101.com/r/TqK3do/1

@mohdlatif
Copy link

mohdlatif commented Oct 24, 2023

Oh and if it helps, heres a regex101 that helped me visualize: https://regex101.com/r/TqK3do/1

Thank you for sharing the regex code, it was not working for dynamic SEO suffix due to the fact, the deliveryType group was restrained with default options, in cloudinary page, there is an option to mainuplate the URL by changing from 'image' to 'images' and removing 'upload/version'/ and add a suffix for seo.

Example:

https://res.cloudinary.com/cloudname/image/upload/v1698107224/location_jr0gqg.jpg

to

https://res.cloudinary.com/cloudname/location_jr0gqg.jpg

to

https://res.cloudinary.com/cloudname/images/location_jr0gqg/Anyname.jpg

Anyways, I have modified the code and added ? to make the selection optional.
image

/https?:\/\/(?<host>[^\/]+)\/(?<cloudName>[^\/]+)\/(?<assetType>image|images|video|videos|raw|files)\/?(?<deliveryType>upload|fetch|private|authenticated|sprite|facebook|twitter|youtube|vimeo)?\/?(?<signature>s--([a-zA-Z0-9\_\-]{8}|[a-zA-Z0-9\_\-]{32})--)?\/?(?<transformations>(?:[^_\/]+_[^,\/]+,?\/?)*\/)*(?<version>v\d+|\w{1,2})\/(?<publicId>[^\s]+)$/gm

I would hope if the developer @ascorbic update the repo and fix the code

image

Many thanks

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