Skip to content

Instantly share code, notes, and snippets.

@Rahe
Created November 13, 2014 22:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rahe/d59c9b4da6f8594658cc to your computer and use it in GitHub Desktop.
Save Rahe/d59c9b4da6f8594658cc to your computer and use it in GitHub Desktop.
Forcer la regénération des images d'un média
<?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