I am looking for a way to use an image url with the WordPress function add_image_size
, I have already setup an image size called 'custom-thumb'
For example, instead of…
the_post_thumbnail( 'custom-thumb' );
Which would output the posts thumbnail at the custom size I specified, I want to do something like…
www.mydomain.com/image.jpg('custom-thumb');
The pattern you posted…
… is a bit odd. That would be pretty tricky. You’d need a PHP handler to load the image and you’d need to tell the server (Apache, Nginx, IIS, Whatever) to parse that file ending as PHP. Something like this would be simpler:
You would still need to create a PHP handler script to read the URL, parse the
GET
string, and display the image.You could probably get something like this…
… working with an endpoint.
However, the easiest thing to do is use
wp_get_attachment_image_src
to create the URL. I don’t know if that is an option for you but there is an example in the Codex:TimThumb (source code) is probably what you think you need, and probably good enough now, considering that it’s been a while since it was last exploited. Like anything else, it comes with its own pros/cons (just google ’em).
But you should know that once you get the hang of
add_image_size
andthe_post_thumbnail
functions you’ll never have to go back.PS: Besides it looks like an XY problem. So, considering that you think X is the solution to problem Y, why don’t you tell us more about Y, and see if we can suggest a better alternative to X?