I’m using a custom field to select an image’s url.
My client is inserting and uploading all the image so this needs to be really simple. Thats why I’m trying to handle it behind the scene.
The problem I’ve run into is all I have in the url of the full size image which is really slowing down load time.
Is there a way I can insert a thumbnail or other image size based on the full size url?
I’ve tried this which sort of works but the problem I’m having is some images don’t have the same dentition, so this needs to be done more dynamical.
<? $reduceimage = str_replace('.jpg', '-330x220.jpg' , $defaultimage); ?>
I think it’s best to rely on wordpress’ native
wp_get_attachment_image_src()
function to get different sizes of image. But to do so, you need attachment ID, not the url.The function to convert the url to ID:
Thanks to Frankie Jarrett.
Then you can get other sizes easily:
If you need link from this image: