⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.173
Server IP:
78.40.11.138
Server:
Linux tango.o2switch.net 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
Server Software:
Apache
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
sc1voni9410
/
View File Name :
fix-inbody-img.php
<?php // Bascule les images in-body des 10 posts programmés vers la taille 'large' (1024px) $q = new WP_Query(['post_type'=>'post','post_status'=>'future','posts_per_page'=>20]); foreach ($q->posts as $p) { $c = $p->post_content; if (!preg_match('#<figure class="wp-block-image"><img src="([^"]+)"#', $c, $m)) { WP_CLI::log("skip {$p->ID} (pas de figure)"); continue; } $src = $m[1]; $att = attachment_url_to_postid($src); if (!$att) { WP_CLI::log("skip {$p->ID} (attachment introuvable pour $src)"); continue; } $l = wp_get_attachment_image_src($att, 'large'); if (!$l || $l[0] === $src) { WP_CLI::log("skip {$p->ID} (déjà optimal)"); continue; } $c = str_replace($src, $l[0], $c); $c = preg_replace('#(<figure class="wp-block-image"><img [^>]*?)width="\d+" height="\d+"#', '${1}width="'.$l[1].'" height="'.$l[2].'"', $c, 1); wp_update_post(['ID'=>$p->ID, 'post_content'=>$c]); WP_CLI::log("OK {$p->ID} -> ".basename($l[0])." ({$l[1]}x{$l[2]})"); }