Usage
PHP
nebula()->post_dimensions($icon, $linked)
Parameters
$icon
(Optional) (Boolean) Whether to show the icon
Default: true
$linked
(Optional) (Boolean) Whether the metadata should be linked
Default: true
Demo
Using post_meta
:
Using individual Nebula post meta functions with options:
Other Nebula meta functions:
Source File
Located in /libs/Functions.php on line 757.
No Hooks
This function does not have any filters or actions available. Request one?
PHP
public function post_dimensions($options=array()){ if ( wp_attachment_is_image() ){ $defaults = array( 'icon' => true, //Show icon 'linked' => true, //Link to attachment ); $data = array_merge($defaults, $options); $the_icon = ''; if ( $data['icon'] ){ $the_icon = '<i class="fa-solid fa-fw fa-expand"></i> '; } $metadata = wp_get_attachment_metadata(); if ( $data['linked'] ){ echo '<span class="meta-item meta-dimensions">' . $the_icon . '<a href="' . wp_get_attachment_url() . '" >' . $metadata['width'] . ' × ' . $metadata['height'] . '</a></span>'; } else { echo '<span class="meta-item meta-dimensions">' . $the_icon . $metadata['width'] . ' × ' . $metadata['height'] . '</span>'; } } }
Override
This function can not be short-circuited with an override filter. Request one?