uploads - media sideload image and Google Content

admin2025-06-02  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 = ""

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?

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/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?

Share Improve this question edited Feb 28, 2019 at 23:00 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Feb 28, 2019 at 19:33 Picard102Picard102 9331 gold badge10 silver badges23 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748853308a314266.html

最新回复(0)