admin管理员组文章数量:1323723
Interesting situation i just ran into.
I have a site I am developing in which I have defined specific image sizes I want created whenever a new image is uploaded. Currently lets just say that I defined a specific thumbnail size of 75x75 and a medium sized image of 150x150 pixels.
Assuming we proceed to upload a new image using the built in media uploader we would expect that Wordpress will automatically upload and store the original image along with any additional images sizes which I have specified in my functions.php file (in this case the 75x75 and 150x150 pixel images).
First of all, the above illustrated example is indeed working perfectly and I am very happy with the results.
What I have noticed though is that when you pick a bmp file to upload the automatic resizing does not take place.
My objective here is to figure out who else might have noticed this issue while attempting to find a solution for this problem. I need to ensure that even when a large bmp file is uploaded that the code
the_post_thumbnail( array(50,50), 'class=alignleft' );
will show the 50x50 pixel image.
Just in case anyone is interested, I have confirmed this issue is specifically related to bmp image by taking the original bmp image and saving it as a jpg and png file through photoshop and then using the wordpress media manager to upload the same files converted by photoshop... In both cases I noticed that after uploading each converted file the exact same images WERE correctly being resized.
I should also point out that when a bmp file image was uploaded the actual upload of that file DID take place however in the media manager only the original (full size) image was available to insert into posts and checking the media upload folder also only showed a single image.
Any guidance, help or diagnosis is greatly appreciated!
Interesting situation i just ran into.
I have a site I am developing in which I have defined specific image sizes I want created whenever a new image is uploaded. Currently lets just say that I defined a specific thumbnail size of 75x75 and a medium sized image of 150x150 pixels.
Assuming we proceed to upload a new image using the built in media uploader we would expect that Wordpress will automatically upload and store the original image along with any additional images sizes which I have specified in my functions.php file (in this case the 75x75 and 150x150 pixel images).
First of all, the above illustrated example is indeed working perfectly and I am very happy with the results.
What I have noticed though is that when you pick a bmp file to upload the automatic resizing does not take place.
My objective here is to figure out who else might have noticed this issue while attempting to find a solution for this problem. I need to ensure that even when a large bmp file is uploaded that the code
the_post_thumbnail( array(50,50), 'class=alignleft' );
will show the 50x50 pixel image.
Just in case anyone is interested, I have confirmed this issue is specifically related to bmp image by taking the original bmp image and saving it as a jpg and png file through photoshop and then using the wordpress media manager to upload the same files converted by photoshop... In both cases I noticed that after uploading each converted file the exact same images WERE correctly being resized.
I should also point out that when a bmp file image was uploaded the actual upload of that file DID take place however in the media manager only the original (full size) image was available to insert into posts and checking the media upload folder also only showed a single image.
Any guidance, help or diagnosis is greatly appreciated!
Share Improve this question edited Oct 13, 2010 at 22:37 NetConstructor asked Oct 13, 2010 at 22:10 NetConstructorNetConstructor 4,40618 gold badges70 silver badges82 bronze badges 6- I don't believe PHP supports BMP files without some help from external functions — for example. – dgw Commented Oct 13, 2010 at 22:19
- @Voyagerfan5761 -- if you (or anyone) happen to know what exactly needs to be added so that I can use the_post_thumbnail( array(75,75), 'class=alignleft' ); for a bmp file I would greatly appreciate it. – NetConstructor Commented Oct 13, 2010 at 22:34
- I have a feeling that adding BMP support is plugin territory, for now. No guarantees, but you can try searching the WP plugin directory. – dgw Commented Oct 13, 2010 at 22:43
- I did not find a plugin that addresses this... anyone? – NetConstructor Commented Oct 14, 2010 at 1:31
- 1 Not answering your question directly... Why the heck you want to use BMP files? :) Such image are basically uncompressed and come in relatively huge sizes. There is no benefit to using BMP but plenty of downsides. – Rarst Commented Oct 14, 2010 at 9:45
2 Answers
Reset to default 5No, wordpress can not resize BMP files. Beware that it does not make sense to use BMP files in a website because a broad number of webbrowsers is not able to display them.
Filetypes that are supported by Wordpress and which are widely supported by internet browsers are: GIF, JPG and PNG.
Those formats are optimized for internet use as they compress image data. BMP is a common image format but not in the internet because it has large file sizes.
This is from another thread, with code that lets you limit the filetypes you allow.
add_filter('wp_handle_upload_prefilter', 'yoursite_wp_handle_upload_prefilter');
function yoursite_wp_handle_upload_prefilter($file) {
// This bit is for the flash uploader
if ($file['type']=='application/octet-stream' && isset($file['tmp_name'])) {
$file_size = getimagesize($file['tmp_name']);
if (isset($file_size['error']) && $file_size['error']!=0) {
$file['error'] = "Unexpected Error: {$file_size['error']}";
return $file;
} else {
$file['type'] = $file_size['mime'];
}
}
list($category,$type) = explode('/',$file['type']);
if ('image'!=$category || !in_array($type,array('jpg','jpeg','gif','png'))) {
$file['error'] = "Sorry, you can only upload a .GIF, a .JPG, or a .PNG image file.";
} else if ($post_id = (isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : false)) {
if (count(get_posts("post_type=attachment&post_parent={$post_id}"))>0)
$file['error'] = "Sorry, you cannot upload more than one (1) image.";
}
return $file;
}
The code is by MikeSchinkel
本文标签: imagesCan Wordpress resize BMP files
版权声明:本文标题:images - Can Wordpress resize BMP files? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742124148a2421861.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论