-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add function to replace URL #34
Comments
You're welcome! We're really happy to hear that. Hmm, currently the regular expression used in To get a better idea of what you're trying to accomplish, can you please share an example of the value(s) that you're wanting to rewrite? For example, the value of the |
Hi @coreykn, Example: Both files will not get loaded from CDN as the files never go through the PHP filters as Solution: I already had various other use cases where I just wanted to get a URL transformed into CDN URL without a file appendix. That is why I used the workaround above in which I temporary add a filename to the URL, pass it to I hope that makes it more clear. :) Kind regards, Philipp |
Thank you for the detailed reply, I really appreciate it. That definitely makes it clear. 🙂 I do believe having this capability would be beneficial and I would like to bring it to CDN Enabler. I have other tasks that are taking priority at the moment, which means I will need to come back to this at a later point of time. A separate method could easily be added to support this, or even updating In the meantime you can continue to use your workaround or come up with a custom function. For example, |
Just wanted to bump this request, and say that I'd love to use it as well. I'm currently using the WordPress API to display posts, and I'm getting a meta field called 'property_images', and as you would expect, it returns the actual URL, and I pass that to the front end. Being able to feed that string/array to a function like @ouun has suggested would be perfect for a situation like this. For the moment, I can simply create a function that changes the URL's before I pass them to the front end, but I would assume if we use the CDN Enabler engine, that would be a much more comprehensive way to do it. My way is quite hacky. |
Actually, I'm not sure if this is 100% how it should be done, but the code I was working with can access the CDN Enabler Engine class, so I can just do this:
This works perfectly. If you can think of why this is a terrible idea, I'd love to hear it so I don't break my production sites lol. |
Dear KeyCDN-Team,
thank you very much for this amazing plugin. The latest updates are amazing!
However a simple helper function to replace a URL with the CDN URL would be awesome. Let's say for some reason I need to get the CDN URL of a path which does not contain one of the "CDN Inclusions". E.g. a hook for
get_template_path()
using the rewrite engine will not change the URL.I have a workaround in place that adds and removes a fake JS file so that CDN Rewrite Engine processes it. However e.g. a simple
get_cdn_url($url)
function that uses the rewrite engine for whatever is passed. That would be awesome and replaces this:The text was updated successfully, but these errors were encountered: