From 7edf9060659f7f0f671144afcd90358fbfb6df65 Mon Sep 17 00:00:00 2001 From: shish Date: Mon, 14 Apr 2008 10:50:46 +0000 Subject: [PATCH] manually set the mime type when serving .ico files git-svn-id: file:///home/shish/svn/shimmie2/trunk@817 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/handle_ico/main.php | 12 ++++++++++++ contrib/handle_ico/theme.php | 8 ++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/contrib/handle_ico/main.php b/contrib/handle_ico/main.php index 90fd90a1..c8b312b0 100644 --- a/contrib/handle_ico/main.php +++ b/contrib/handle_ico/main.php @@ -37,6 +37,18 @@ class IcoFileHandler extends Extension { if(is_a($event, 'DisplayingImageEvent') && $this->supported_ext($event->image->ext)) { $this->theme->display_image($event->page, $event->image); } + + if(is_a($event, 'PageRequestEvent') && ($event->page_name == "get_ico")) { + global $database; + $id = int_escape($event->get_arg(0)); + $image = $database->get_image($id); + $hash = $image->hash; + $ha = substr($hash, 0, 2); + + $event->page->set_type("image/x-icon"); + $event->page->set_mode("data"); + $event->page->set_data(file_get_contents("images/$ha/$hash")); + } } private function supported_ext($ext) { diff --git a/contrib/handle_ico/theme.php b/contrib/handle_ico/theme.php index 49c8a666..32baef06 100644 --- a/contrib/handle_ico/theme.php +++ b/contrib/handle_ico/theme.php @@ -2,13 +2,9 @@ class IcoFileHandlerTheme extends Themelet { public function display_image($page, $image) { - $ilink = $image->get_image_link(); - $width = $image->width; - $height = $image->height; + $ilink = make_link("get_ico/{$image->id}/{$image->id}.ico"); $html = " - - - + "; $page->add_block(new Block("Image", $html, "main", 0)); }