Last active
May 2, 2022 17:56
-
-
Save landbryo/f8cc3bfd0710f35e623307f21fc8bfab to your computer and use it in GitHub Desktop.
Fix picker image meta for MG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* After attachment has been created, make sure to | |
* label it as an external image source so the URL can be re-written. | |
*/ | |
add_filter( 'capi_image_attachment_meta', function( $metadata, $attachment_id ) { | |
// Mark as external image source. | |
update_post_meta( $attachment_id, '_external_image_source', 1 ); | |
return $metadata; | |
}, 10, 2 ); | |
/** | |
* Set both `url` and `file` bits to original resource URL instead of WP asset. | |
*/ | |
add_filter( 'capi_image_upload_bits', function( $upload, $post_id, $url ) { | |
$upload['url'] = $url; | |
$upload['file'] = $url; | |
return $upload; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment