Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
    
I don't believe PHP supports BMP files without some help from external functions — for example. –  dgw Oct 13 '10 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.com Oct 13 '10 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 Oct 13 '10 at 22:43
    
I did not find a plugin that addresses this... anyone? –  NetConstructor.com Oct 14 '10 at 1:31
    
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 Oct 14 '10 at 9:45
show 1 more comment

2 Answers

up vote 5 down vote accepted

No, 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.

share|improve this answer
    
Hey man, thanks for the update there. What was confusing to me was that wordpress seems to allow the bmp files to be uploaded by default. Could you update your answer and post the code which would prevent bmp files from being uploaded/supported mime type? –  NetConstructor.com Oct 14 '10 at 22:13
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.