Open GoogleCodeExporter opened 8 years ago
Confirmed that this is a problem and that the mentioned fix works. An
improvement on the above code, placed underneath the getAttachments method
definition:
/**
* Returns the image attachments
* @return Array
*/
public function getImages() {
$images = array();
$types = array("image/jpeg", "image/png");
foreach($this->parts as $part) {
$type = $this->getPartContentType($part);
if(in_array($type, $types)) {
$images[] = new MimeMailParser_attachment(
$part['content-name'],
$type,
$this->getAttachmentStream($part),
null,
$this->getPartHeaders($part)
);
}
}
return $images;
}
This version gives the MimeMailParser_attachment more information. In
particular, $attachment->filename should work properly this way.
Original comment by Daniel.S...@gmail.com
on 29 Dec 2011 at 4:45
Further information: This seems to be an issue with certain email clients not
adding a Content-Disposition header to some image attachments.
Original comment by Daniel.S...@gmail.com
on 29 Dec 2011 at 5:05
I've added you guys to the project contributors so you can commit to SVN. Feel
free to add the patch.
Maybe it should do a regular expression match for image types instead?
/**
* Returns the image attachments
* @return Array
*/
public function getImages() {
$images = array();
$types = "/^image\/(.*)$/";
foreach($this->parts as $part) {
$type = $this->getPartContentType($part);
if(preg_match($types, $type)) {
$images[] = new MimeMailParser_attachment(
$part['content-name'],
$type,
$this->getAttachmentStream($part),
null,
$this->getPartHeaders($part)
);
}
}
return $images;
}
Original comment by buca...@gmail.com
on 30 Dec 2011 at 3:36
Original issue reported on code.google.com by
andrewp...@gmail.com
on 26 Feb 2011 at 6:47