Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Certificates::get_image_data_and_type( string $image_src, boolean $allowed_only = true )
Get image data and type given its source URL
Parameters Parameters
- $image_src
-
(string) (Required) The image src.
- $allowed_only
-
(boolean) (Optional) Get only images whose host is not in the
export_blocked_image_hosts
list.Default value: true
Return Return
(array|false)
Source Source
File: includes/class.llms.certificates.php
private function get_image_data_and_type( $image_src, $allowed_only = true ) { $src_host = wp_parse_url( $image_src, PHP_URL_HOST ); // Only include images from non blocked hosts. if ( $allowed_only && in_array( $src_host, $this->export_blocked_image_hosts, true ) ) { return false; } if ( in_array( $src_host, $this->export_local_hosts, true ) ) { // Is local? $imgpath = untrailingslashit( ABSPATH ) . wp_parse_url( $image_src, PHP_URL_PATH ); $data = file_get_contents( $imgpath ); // phpcs:ignore WordPress.WP.AlternativeFunctions -- getting a local file. $type = LLMS_Mime_Type_Extractor::from_file_path( $imgpath ); } else { $response = wp_remote_get( $image_src ); $data = wp_remote_retrieve_body( $response ); $type = wp_remote_retrieve_header( $response, 'content-type' ); } return compact( 'data', 'type' ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.21.0 | Introduced. |