Merge pull request #81 from BenLubar-PR/attachment-alt-text

This commit is contained in:
Matthias Pfefferle 2020-01-18 20:44:16 +01:00 committed by GitHub
commit cb29fe360b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -96,32 +96,24 @@ class Post {
// get URLs for each image
foreach ( $image_ids as $id ) {
$alt = \get_post_meta( $id, '_wp_attachment_image_alt', true );
$thumbnail = \wp_get_attachment_image_src( $id, 'full' );
$mimetype = \get_post_mime_type( $id );
if ( $thumbnail ) {
$images[] = array(
'url' => $thumbnail[0],
'type' => $mimetype,
);
}
}
$attachments = array();
// add attachments
if ( $images ) {
foreach ( $images as $image ) {
$attachment = array(
$image = array(
'type' => 'Image',
'url' => $image['url'],
'mediaType' => $image['type'],
'url' => $thumbnail[0],
'mediaType' => $mimetype
);
$attachments[] = $attachment;
if ( $alt ) {
$image['name'] = $alt;
}
$images[] = $image;
}
}
return $attachments;
return $images;
}
public function get_tags() {