1

I'm trying to take a pages og:image from a URL and add it to the media library and post meta. Works great until I hit a google user content url.

$image_url = "https://lh3.googleusercontent.com/ApY_G9QDLuhi5pUrrHnUma72_MnSjP6ZN-N6qqRIpWARO-67CmGWsYB9vrTyIEbqm2SUcQ=w1200-h630-p"

media_sideload_image( $image_url, $post_id, '', 'src' );

Results in "not valid image url". I would guess it has to do with how the google image url for og:image doesn't have any type of image extension on it. Is there a work around for this?

1

I did a little searching and it looks like maybe you can fix it by appending ?.jpg to the end of the URL. According to this guide that gets around most URL parsers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.