首页 WordPress函数大全 media_sideload_image()

media_sideload_image()

2020-05-02 / 2687阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

media_sideload_image( string $file, int $post_id, string $desc = null, string $return = 'html' )

从指定的URL下载图像并将其附加到帖子。

描述

参数

$file

(string)
(Required)
The URL of the image to download.

$post_id

(int)
(Optional)
The post ID the media is to be associated with.

$desc

(string)
(Optional)
Description of the image.

Default value: null

$return

(string)
(Optional)
Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID).

Default value: 'html'

返回

(string|WP_Error) Populated HTML img tag>WP_Error object otherwise.

大家谈论
    我的见解