如何停止从解析器生成不同大小的图像

时间:2016-09-22 作者:Aftab

我正在创建一个解析器,用于解析XML文件并将图像上载到媒体库。一切正常。

但上传后,也会根据媒体设置生成不同的图像。例如:中等、缩略图等。

我想停止仅为这些图像(通过解析上传的图像)生成不同大小的重复图像。这可能吗?

require_once( ABSPATH . \'wp-admin/includes/image.php\' );
$filetype = wp_check_filetype( basename( $uploadfile ), null );

$attachment = array(
    \'guid\'           => basename( $uploadfile ),
    \'post_mime_type\' => $filetype[\'type\'],
    \'post_title\'     => preg_replace( \'/\\.[^.]+$/\', \'\', basename( $uploadfile ) ),
    \'post_content\'   => \'\',
    \'post_status\'    => \'inherit\',
);

$attach_id   = wp_insert_attachment( $attachment, $uploadfile );

$attach_data = wp_generate_attachment_metadata( $attach_id, $uploadfile );

wp_update_attachment_metadata( $attach_id, $attach_data );

return $attach_id;

1 个回复
最合适的回答,由SO网友:Aftab 整理而成

我们不能这样做。就这么简单

相关推荐

Images with overlay

我有一些图片在一个容器中,我想添加一个覆盖和图标。这不是现成的,但我找到了一些有用的代码:HTML:<div class=\"main\"> <span class=\"featured\"><img src=\"http://joshrodg.com/IMG_001-258x258.jpg\" title=\"\" alt=\"\"></span> </div> CSS:.featured {