Ankit您可以通过终端使用此脚本重新调整图像大小:
<?php
ini_set(\'max_execution_time\', 0);
set_time_limit(0);
require_once(\'./wp-load.php\');
require_once( \'./wp-admin/includes/admin.php\' );
for($i=0;$i<=500;$i++){
$attachments =& get_children(array(
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
\'numberposts\' => 50,
\'paged\' => $i,
\'post_status\' => null,
\'post_parent\' => null
), ARRAY_A);
foreach ( $attachments as $attachment ) {
$image = get_post($attachment[\'ID\']);
$original_size_path = get_attached_file($image->ID);
if (false === $original_size_path || !file_exists($original_size_path)) {
echo \'File Not Found: \';
} else {
$metadata = wp_generate_attachment_metadata($image->ID, $original_size_path);
if (is_wp_error($metadata) || empty($metadata))
echo \'Unknown failure reason: \'. $original_size_path;
wp_update_attachment_metadata($image->ID, $metadata);
}
}
echo \'Done page \'. $i.\' ====== \';
mail(\'[email protected]\',(\'Page\'.$i.\'done\'),(\'Page\'.$i.\'done\'));
unset($attachments);
unset($image);
unset($original_size_path);
unset($metadata);
sleep(1);
}
mail(\'[email protected];\',\'Done\',\'Done Images Thumbnail Generation\');
?>
您只需更改for loop中$i的值和您的电子邮件地址。将此文件另存为“something.php”,并通过ssh在终端中运行此文件。希望这有帮助。