Open rjdusk opened 1 year ago
Hi,
Thanks for reporting this and I apologize for the late reply. I will investigate and get back with an update.
same issue here, all my urls look like this. I think it does not work when you host your blog as https://www.mydomain.com/subdirectory/wp-content
same issue here, all my urls look like this. I think it does not work when you host your blog as https://www.mydomain.com/subdirectory/wp-content
It should work if you set the site URL. Try to edit config.php manually and set the URL there.
here is my setup explained:
I have domain lets call it example.com, this domain purely runs NextJS and all of it is behind CloudFlare, that's my main website and contains a lot of stuff regarding just website, nothing to do with wordpress,
I've also now set up a custom wordpress(hosting it call it wordpress.com), and I am using CloudFlare 'proxy/mirroring' to essentially 'host it / mirror it' at
This is done through CloudFlare worker that rewrites urls on the fly. So far so good. I experiemnted with a lot of wordpress plugins and they all seemed really weird and complicated, until I saw this, which is more or less how I do my main website images anyways, through CloudFlare cdn-cgi.
So for reference, if I want to resize images I need to pass them through https://example.com/cdn-cgi (note without /blog).
I have now tried this plugin, and what it seems to do is to write all of the images/other urls to this format (paraphrased more or less as I don't have direct access to links right now, but the idea is right):
srcset=https://example.com/blog/cdn-cgi/format=auto,onerror=reject/wp-content/uploads/image.jpg
this is not correct, but this is:
srcset=https://example.com/cdn-cgi/format=auto,onerror=reject/blog/wp-content/uploads/image.jpg
For now, I changed/hardcoded everything myself to make it work, however I have no generic solution to share.
here is my setup explained:
I have domain lets call it example.com, this domain purely runs NextJS and all of it is behind CloudFlare, that's my main website and contains a lot of stuff regarding just website, nothing to do with wordpress,
I've also now set up a custom wordpress(hosting it call it wordpress.com), and I am using CloudFlare 'proxy/mirroring' to essentially 'host it / mirror it' at
This is done through CloudFlare worker that rewrites urls on the fly. So far so good. I experiemnted with a lot of wordpress plugins and they all seemed really weird and complicated, until I saw this, which is more or less how I do my main website images anyways, through CloudFlare cdn-cgi.
So for reference, if I want to resize images I need to pass them through https://example.com/cdn-cgi (note without /blog).
I have now tried this plugin, and what it seems to do is to write all of the images/other urls to this format (paraphrased more or less as I don't have direct access to links right now, but the idea is right):
srcset=https://example.com/blog/cdn-cgi/format=auto,onerror=reject/wp-content/uploads/image.jpg
this is not correct, but this is:
srcset=https://example.com/cdn-cgi/format=auto,onerror=reject/blog/wp-content/uploads/image.jpg
For now, I changed/hardcoded everything myself to make it work, however I have no generic solution to share.
Your situation is unique, however when using the worker you have full control over the code and you can manually change it to reflect your needs. It grabs by default /blog because that's where your images are coming from, this is not a bug; it works as expected. Your only option in this situation remains manual adjusting to grab the images from your desired location.
Hi @Mecanik, firstly thank you so much for this worker code, I've been using it to great success on a WordPress website I manage.
However I've noticed a few line in my server error logs that look like this:
Any idea what maybe causing these errors? It looks like the onerror redirect is a relative URL instead of an absolute URL. Probably some config I may have missed, but I can't see where. Thanks!