8000 Simplify media file detection · SuperConnvrd/codebird-php@da26b88 · GitHub
[go: up one dir, main page]

Skip to content

Commit da26b88

Browse files
committed
Simplify media file detection
1 parent b6af091 commit da26b88

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/codebird.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,27 +1068,19 @@ protected function _buildMultipart($method, $params)
10681068

10691069
// is it a valid image?
10701070
&& $data = @getimagesize($value)
1071+
// is it a supported image format?
1072+
&& in_array($data[2], $this->_supported_media_files)
10711073
) {
1072-
if (// is it a supported image format?
1073-
in_array($data[2], $this->_supported_media_files)
1074-
) {
1075-
// try to read the file
1076-
ob_start();
1077-
readfile($value);
1078-
$data = ob_get_contents();
1079-
ob_end_clean();
1080-
if (strlen($data) === 0) {
1081-
continue;
1082-
}
1083-
$value = $data;
1074+
// try to read the file
1075+
ob_start();
1076+
readfile($value);
1077+
$data = ob_get_contents();
1078+
ob_end_clean();
1079+
if (strlen($data) === 0) {
1080+
continue;
10841081
}
1082+
$value = $data;
10851083
}
1086-
1087-
/*
1088-
$multipart_request .=
1089-
"\r\nContent-Transfer-Encoding: base64";
1090-
$value = base64_encode($value);
1091-
*/
10921084
}
10931085

10941086
$multipart_request .=

0 commit comments

Comments
 (0)
0