Programmatically regenerate thumbnails
-
Hello,
I’m currently developing a website for a client and I would like to know if it is possible to do the following :
– Regenerate thumbnails programmatically, in PHP, within a scheduled task.As I didn’t find any documentation about it, I just watched the requests involved when clicking the “Regenerate all thumbnails” button. For now, I’ve succeed to retrieve the medias IDs via : “/wp-json/wp/v2/media?page=1&per_page=100&_fields=id&is_regeneratable=1&exclude_site_icons=1&orderby=id&order=asc” using curl.
Though, I can’t regenerate thumbnails using this URL (971 is an ID used for the example) : “/wp-json/regenerate-thumbnails/v1/regenerate/971?only_regenerate_missing_thumbnails=true&delete_unregistered_thumbnail_files=false&update_usages_in_posts=false”. When I do, I get this error message :
“{ [“code”]=> string(14) “rest_forbidden” [“message”]=> string(59) “Désolé, vous n’avez pas l’autorisation de faire cela.” [“data”]=> array(1) { [“status”]=> int(401) } }”Am I correct in my approach? Do I use the good URLs? Does it involve an authentication? Any support would be great 🙂
Thank you, and I look forward to hear about you !
The topic ‘Programmatically regenerate thumbnails’ is closed to new replies.