• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Jetpack a2z

Jetpack a2z

Jetpack a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WPCOM_JSON_API_Post_Endpoint::get_attachment() – Returns attachment object.

You appear to be a bot. Output may be restricted

Description

Returns attachment object.

Usage

$object = WPCOM_JSON_API_Post_Endpoint::get_attachment( $attachment );

Parameters

$attachment
( mixed ) required –

Returns

object

Source

File name: jetpack/json-endpoints/class.wpcom-json-api-post-endpoint.php
Lines:

1 to 18 of 18
  function get_attachment( $attachment ) {
    $metadata = wp_get_attachment_metadata( $attachment->ID );

    $result = array(
      'ID'    => (int) $attachment->ID,
      'URL'           => (string) wp_get_attachment_url( $attachment->ID ),
      'guid'    => (string) $attachment->guid,
      'mime_type'  => (string) $attachment->post_mime_type,
      'width'    => (int) isset( $metadata['width']  ) ? $metadata['width']  : 0,
      'height'  => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0,
    );

    if ( isset( $metadata['duration'] ) ) {
      $result['duration'] = (int) $metadata['duration'];
    }

    return (object) apply_filters( 'get_attachment', $result );
  }
 

 View on GitHub View on Trac

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

Published: 27 November 2019 | Last updated: 27 November 2019

Primary Sidebar

Information

Function name: WPCOM_JSON_API_Post_Endpoint::get_attachment
Class ref: WPCOM_JSON_API_Post_Endpoint
Plugin ref: Jetpack
Version: 9.2
Sourcefile: json-endpoints/class.wpcom-json-api-post-endpoint.php
File ref: json-endpoints/class.wpcom-json-api-post-endpoint.php
Deprecated?: No
API Letters: A,E,J,P,W

Footer

Jetpack a2z
Jetpack a2z
Jetpack a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  jetpack.wp-a2z.org
© Copyright Jetpack a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites