LLMS_Abstract_Generator_Posts::set_featured_image( string $url_or_raw, int $post_id )
Saves an image (from URL) to the media library and sets it as the featured image for a given post
Parameters Parameters
- $url_or_raw
-
(string) (Required) Array of raw data or URL to an image.
- $post_id
-
(int) (Required) WP Post ID.
Return Return
(null|false|int) Returns null
if sideloading is disabled, WP Post ID of the attachment on success, false
on error.
Source Source
File: includes/abstracts/llms-abstract-generator-posts.php
* * @since 4.7.0 * * @return void */ protected function load_dependencies() { // For featured image creation via `media_sideload_image()`. require_once ABSPATH . 'wp-admin/includes/media.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; } /** * Saves an image (from URL) to the media library and sets it as the featured image for a given post * * @since 3.3.0 * @since 4.7.0 Moved from `LLMS_Generator` and made `protected` instead of `private`. * Add a return instead of `void`; Don't import if sideloading is disabled; Use `$this->sideload_image()` sideloading. *
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.7.0 | Moved from LLMS_Generator and made protected instead of private . Add a return instead of void ; Don't import if sideloading is disabled; Use $this->sideload_image() sideloading. |
3.3.0 | Introduced. |