Skip to content

Commit 94bffcc

Browse files
authored
Add Featured Image Support (#240)
1 parent de29c81 commit 94bffcc

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

includes/class-micropub-endpoint.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ private static function mp_to_wp( $mf2 ) {
717717
*
718718
*/
719719
public static function default_file_handler( $post_id ) {
720-
foreach ( array( 'photo', 'video', 'audio' ) as $field ) {
720+
foreach ( array( 'photo', 'video', 'audio', 'featured' ) as $field ) {
721721
$props = mp_get( static::$input, 'properties' );
722722
$att_ids = array();
723723

@@ -755,6 +755,10 @@ public static function default_file_handler( $post_id ) {
755755
if ( is_micropub_error( $id ) ) {
756756
return $id;
757757
}
758+
// There should only be one of these.
759+
if ( 'featured' === $field ) {
760+
set_post_thumbnail( $post_id, $id );
761+
}
758762
$att_urls[] = wp_get_attachment_url( $id );
759763
}
760764
// Add to the input so will be visible to the after_micropub action

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ into markdown and saved to readme.md.
219219
* Switch check in permissions to whether a user was logged in.
220220
* Published, updated, name, and summary properties are no longer stored in post meta. When queried, they will be pulled from the equivalent WordPress properties. Content should be as well, however as content in the post includes rendered microformats we need to store the pure version. Might address this in a future version.
221221
* As timezone is not stored in the WordPress timestamp, store the timezone offset for the post in meta instead.
222+
* Sideload and set featured images if featured property is set.
222223

223224
### 2.2.2 (2020-08-23 )
224225

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ into markdown and saved to readme.md.
219219
* Switch check in permissions to whether a user was logged in.
220220
* Published, updated, name, and summary properties are no longer stored in post meta. When queried, they will be pulled from the equivalent WordPress properties. Content should be as well, however as content in the post includes rendered microformats we need to store the pure version. Might address this in a future version.
221221
* As timezone is not stored in the WordPress timestamp, store the timezone offset for the post in meta instead.
222+
* Sideload and set featured images if featured property is set.
222223

223224
= 2.2.2 (2020-08-23 ) =
224225
* Fixed and updated testing environment

0 commit comments

Comments
 (0)