Created
November 13, 2014 22:02
-
-
Save Rahe/d59c9b4da6f8594658cc to your computer and use it in GitHub Desktop.
Forcer la regénération des images d'un média
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 | |
/* | |
Parfois lors de la modification de l'image source d'un article à travers le wp_image_editor, | |
on veut que WordPress regénère les thumbnails associées, voici le moyen de le faire le plus simplement | |
*/ | |
/** | |
* Rebuilt the image sizes | |
* | |
* @param $att_id | |
* | |
* @author Nicolas Juen | |
*/ | |
function regenrate_thumbnails( $att_id ) { | |
delete_post_meta( $att_id, '_wp_attachment_metadata' ); | |
wp_maybe_generate_attachment_metadata( get_post( $att_id ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment