3

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!

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

2 Answers 2

5

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.

3
  • 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? Oct 14, 2010 at 22:13
  • @NetConstructor.com , actually is that another question but maybe this little snippet helps you out to prevent bmp's ?!. add_filter('upload_mimes','remove_unwanted_mime_types'); function remove_unwanted_mime_types($mimes){ unset( $mimes['bmp'] ); } Not tested but should do the job imho. Oeps... very old topic, I will leave this here anyway.
    – Charles
    Jan 18, 2016 at 19:03
  • BMP is common just because windows os uses'em..or rather used to use
    – Vishwa
    May 22, 2019 at 11:28
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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