Skip to Content
Menu

post_dimensions()

Show the post dimensions metadata.

PHP July 20, 2017

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

Request or provide clarification »

Demo


Using post_meta:
Using individual Nebula post meta functions with options:
  • Posted in PHP by
  • Modified on
  • Custom Format:
Other Nebula meta functions:
  • Function
  • No EXIF data found
Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Functions.php on line 682.

    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'] . ' &times; ' . $metadata['height'] . '</a></span>';
                    } else {
                        echo '<span class="meta-item meta-dimensions">' . $the_icon . $metadata['width'] . ' &times; ' . $metadata['height'] . '</span>';
                    }
                }
            }
    

    Override

    This function can not be short-circuited with an override filter. Request one?