wp_object->ID ); $media_type = preg_replace( '/(\/[a-zA-Z]+)/i', '', $mime_type ); switch ( $media_type ) { case 'audio': case 'video': $type = 'Document'; break; case 'image': $type = 'Image'; break; } $attachment = array( 'type' => $type, 'url' => wp_get_attachment_url( $this->wp_object->ID ), 'mediaType' => $mime_type, ); $alt = \get_post_meta( $this->wp_object->ID, '_wp_attachment_image_alt', true ); if ( $alt ) { $attachment['name'] = $alt; } return $attachment; } }