Changeset 19cc5b9 in github for program/steps/mail/func.inc
- Timestamp:
- May 30, 2012 5:22:18 AM (12 months ago)
- Branches:
- master, HEAD, dev-browser-capabilities, pdo
- Children:
- d901205
- Parents:
- b9854b8
- File:
-
- 1 edited
-
program/steps/mail/func.inc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/steps/mail/func.inc
r7c1231a r19cc5b9 1098 1098 } 1099 1099 1100 // Skip TIFF images if browser doesn't support this format1101 // @TODO: we could convert TIFF to JPEG and display it1102 $tiff_support = !empty($_SESSION['browser_caps']) && !empty($_SESSION['browser_caps']['tif']);1103 $mime_regex = $tiff_support ? '/^image\//i' : '/^image\/(?!tif)/i';1104 $ext_regex = '/\.(jpg|jpeg|png|gif|bmp' . ($tiff_support ? '|tif|tiff' : '') .')$/i';1105 1106 1100 // list images after mail body 1107 1101 if ($CONFIG['inline_images'] && !empty($MESSAGE->attachments)) { … … 1113 1107 1114 1108 // Content-Type: image/*... 1115 if (preg_match($mime_regex, $attach_prop->mimetype) || 1116 // ...or known file extension: many clients are using application/octet-stream 1117 ($attach_prop->filename && 1118 preg_match('/^application\/octet-stream$/i', $attach_prop->mimetype) && 1119 preg_match($ext_regex, $attach_prop->filename)) 1120 ) { 1109 if (rcmail_part_image_type($attach_prop)) { 1121 1110 $out .= html::tag('hr') . html::p(array('align' => "center"), 1122 1111 html::img(array( … … 1136 1125 } 1137 1126 1127 function rcmail_part_image_type($part) 1128 { 1129 $rcmail = rcmail::get_instance(); 1130 1131 // Skip TIFF images if browser doesn't support this format... 1132 $tiff_support = !empty($_SESSION['browser_caps']) && !empty($_SESSION['browser_caps']['tif']); 1133 // until we can convert them to JPEG 1134 $tiff_support = $tiff_support || $rcmail->config->get('im_convert_path'); 1135 1136 // Content-type regexp 1137 $mime_regex = $tiff_support ? '/^image\//i' : '/^image\/(?!tif)/i'; 1138 1139 // Content-Type: image/*... 1140 if (preg_match($mime_regex, $part->mimetype)) { 1141 return $part->mimetype; 1142 } 1143 1144 // Many clients use application/octet-stream, we'll detect mimetype 1145 // by checking filename extension 1146 1147 // Supported image filename extensions to image type map 1148 $types = array( 1149 'jpg' => 'image/jpeg', 1150 'jpeg' => 'image/jpeg', 1151 'png' => 'image/png', 1152 'gif' => 'image/gif', 1153 'bmp' => 'image/bmp', 1154 ); 1155 if ($tiff_support) { 1156 $types['tif'] = 'image/tiff'; 1157 $types['tiff'] = 'image/tiff'; 1158 } 1159 1160 if ($part->filename 1161 && preg_match('/^application\/octet-stream$/i', $part->mimetype) 1162 && preg_match('/\.([^.])$/i', $part->filename, $m) 1163 && ($extension = strtolower($m[1])) 1164 && isset($types[$extension]) 1165 ) { 1166 return $types[$extension]; 1167 } 1168 } 1138 1169 1139 1170 /**
Note: See TracChangeset
for help on using the changeset viewer.
