Astra_Customizer::generate_logo_by_width( int $custom_logo_id )
Generate logo image by its width.
Description
Parameters
- $custom_logo_id
-
(int) (Required) Logo id.
Source
File: inc/customizer/class-astra-customizer.php
public static function generate_logo_by_width( $custom_logo_id ) {
if ( $custom_logo_id ) {
$image = get_post( $custom_logo_id );
if ( $image ) {
$fullsizepath = get_attached_file( $image->ID );
/** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
if ( false !== $fullsizepath || file_exists( $fullsizepath ) ) {
if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) {
require_once ABSPATH . 'wp-admin/includes/image.php';// phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
}
$metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
if ( ! is_wp_error( $metadata ) && ! empty( $metadata ) ) {
wp_update_attachment_metadata( $image->ID, $metadata );
}
}
}
}
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |