From 133e887f509e43922b21b962ce7c1d99eab8b7a9 Mon Sep 17 00:00:00 2001 From: betateilchen <> Date: Sat, 31 Jan 2015 18:52:28 +0000 Subject: [PATCH] contrib/InfoPanel: use FileRead for images git-svn-id: https://svn.fhem.de/fhem/trunk@7804 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/InfoPanel/55_InfoPanel.pm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fhem/contrib/InfoPanel/55_InfoPanel.pm b/fhem/contrib/InfoPanel/55_InfoPanel.pm index d96d66dcf..0fe454e8f 100644 --- a/fhem/contrib/InfoPanel/55_InfoPanel.pm +++ b/fhem/contrib/InfoPanel/55_InfoPanel.pm @@ -270,13 +270,21 @@ sub btIP_itemImg { my ($data,$info,$width,$height,$mimetype,$output); if($srctype eq 'file') { + my (@d,$err); + $err = ""; + Log3(undef,4,"InfoPanel img name: $arg"); - my $length = -s "$arg"; - Log3(undef,4,"InfoPanel img len : $length"); - open(GRAFIK, "<", $arg) or die("File not found $!"); - binmode(GRAFIK); - my $readBytes = read(GRAFIK, $data, $length); - close(GRAFIK); + ($err,@d) = FileRead($arg); + if($err && configDBUsed()) { + # not found in database, try to read from filesystem + Log3(undef,4,"Infopanel forced read $arg"); + $err = undef; + ($err,@d) = FileRead({FileName => $arg, ForceType =>'file'}); + Log3(undef,4,"Infopanel: forced read error file: $arg") if $err; + Log3(undef,4,"Infopanel: forced read found: $arg") if !$err; + } + $data = join("",@d) unless $err; + } elsif ($srctype eq "url" || $srctype eq "urlq") { if($srctype eq "url") { $data= GetFileFromURL($arg,3,undef,1);