Created
February 18, 2019 21:19
-
-
Save danielbachhuber/aad495d331f45d4a0ecd97f9f243b9e6 to your computer and use it in GitHub Desktop.
Prevent image thumbnails from being created during import
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
<?php | |
/** | |
* Filtering 'intermediate_image_sizes_advanced' to return an empty array | |
* prior to calling media_sideload_image() will prevent thumbnails from being created. | |
*/ | |
add_filter( 'intermediate_image_sizes_advanced', '__return_empty_array' ); | |
$attachment_id = media_sideload_image( $image_url, $post_id, '', 'id' ); | |
remove_filter( 'intermediate_image_sizes_advanced', '__return_empty_array' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment