如何自动使用调整大小的图像而不是原稿| Wordpress
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何自动使用调整大小的图像而不是原稿| Wordpress相关的知识,希望对你有一定的参考价值。
Place snippet in functions.php, edit maximum image size in Admin -> Settings -> Media -> Image Sizes ("Large Size") (Wordpress 3.1)
function replace_uploaded_image($image_data) { // if there is no large image : return // paths to the uploaded image and the large image $upload_dir = wp_upload_dir(); $uploaded_image_location = $upload_dir['basedir'] . '/' .$image_data['file']; $large_image_location = $upload_dir['path'] . '/'.$image_data['sizes']['large']['file']; // delete the uploaded image // rename the large image // update image metadata and return them $image_data['width'] = $image_data['sizes']['large']['width']; $image_data['height'] = $image_data['sizes']['large']['height']; return $image_data; } add_filter('wp_generate_attachment_metadata','replace_uploaded_image');
以上是关于如何自动使用调整大小的图像而不是原稿| Wordpress的主要内容,如果未能解决你的问题,请参考以下文章