Skip to content

Commit e45ef34

Browse files
committed
Refactor _checkForFiles to use _buildBinaryBody
1 parent 79b9998 commit e45ef34

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

src/codebird.php

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,31 +1722,11 @@ protected function _checkForFiles($method_template, $key, $value) {
17221722
if (!in_array($key, self::$_possible_files[$method_template])) {
17231723
return false;
17241724
}
1725-
if (// is it a file, a readable one?
1726-
@file_exists($value)
1727-
&& @is_readable($value)
1728-
) {
1729-
// is it a supported image format?
1730-
$data = @getimagesize($value);
1731-
if ((is_array($data) && in_array($data[2], $this->_supported_media_files))
1732-
|| imagecreatefromwebp($data) // A WebP image! :-) —why won’t getimagesize support this?
1733-
) {
1734-
// try to read the file
1735-
$data = @file_get_contents($value);
1736-
if ($data !== false && strlen($data) !== 0) {
1737-
return $data;
1738-
}
1739-
}
1740-
} elseif (// is it a remote file?
1741-
filter_var($value, FILTER_VALIDATE_URL)
1742-
&& preg_match('/^https?:\/\//', $value)
1743-
) {
1744-
$data = $this->_fetchRemoteFile($value);
1745-
if ($data !== false) {
1746-
return $data;
1747-
}
1725+
$data = $this->_buildBinaryBody($value);
1726+
if ($data === $value) {
1727+
return false;
17481728
}
1749-
return false;
1729+
return $data;
17501730
}
17511731

17521732

0 commit comments

Comments
 (0)