Man könnte auch den Umweg über die Festplatte sparen und es innerhalb des php Scripts schon nur in einer Variable (die damit automatisch nur im Speicher ist) halten.
Ankündigung
Einklappen
Keine Ankündigung bisher.
Chrome zeigt Image von Mobotix Türstation nicht an
Einklappen
X
-
Du kannst in die camimage.php hinter die Zeile, wo $filepath zugewiesen wird, ein
Code:echo($filepath);
Code:GET http://localhost/smartVISU/pages/<DeineSeiten>/camimage.php?cam=haustuer&url=http://admin:xxxxxxxx@192.168.yyy.yyy/record/current.jpg&_=1640270894254
Hab inzwischen mal das Skript eingedampft und bei mir funzt das tatsächlich mit EDGE und FF.
Code:<?php $url = ""; if(!isset($_GET['cam']) || !isset($_GET['url'])) error("failed"); $url = $_GET['url']; readfile($url); flush(); function error($msg) { header("Content-Type: text/plain; charset=UTF-8"); die("Error: " . $msg); } ?>
Bin auf das professionelle Testergebnis gespannt.
Gruß
WolframZuletzt geändert von wvhn; 23.12.2021, 15:59.
Kommentar
-
Professionelles Testergebnis: Läuft!
Hab im Chrome alles was ich gefunden habe vorher gelöscht, also Cookies, Webseitendaten, Cache.
Wenn ich nichts übersehen habe war er also blank und das Bild wird angezeigt. Alles gut. So einfach kann es sein
Im FF klappts auch. Da hab ich aber jetzt nicht alle Cache Daten usw. gelöscht.
P.S. Damit ist mir natürlich auch egal, wo die temporäre Datei eigentlich gelandet ist
P.P.S Performance ist super. Da traue ich mir ja fast die Abfragezeit zu verkürzen.Zuletzt geändert von Sipple; 23.12.2021, 16:28.
Kommentar
-
Hier mit ein bisschen mehr Fehlerhandling.
PHP-Code:<?php
if(!isset($_GET['url'])) {
error('URL missing');
}
$url = $_GET['url'];
$file_headers = @get_headers($url);
if($file_headers || $file_headers[0] == 'HTTP/1.1 200 OK') {
header($file_headers[1]);
readfile($url);
}
else {
error('URL doesn\'t exist');
}
function error($msg) {
header('Content-Type: text/plain; charset=UTF-8');
die('Error: ' . $msg);
}
?>
Dann könnte man mit folgender Codezeile auskommen:
PHP-Code:<?php
readfile($_GET['url']);
?>Zuletzt geändert von stoepf; 23.12.2021, 17:48.
- Likes 1
Kommentar
-
Letzte Aktion vor Weihnachten- Einen neuen Ordner ./lib/multimedia anlegen und camimage.php dorthin speichern bzw. verschieben.
- in der ./widgets/multimedia.html das Macro "image" austauschen:
Code:/** * Displays an image witch is been reloaded after a given time * * @param {id=} unique id for this widget * @param {text} the path/url or item to the image. For squeezebox create an item with the following value: 'http://IP:PORT/music/current/cover.jpg?player=MACADDRESS' * @param {text(none,corner,corner-bottom,fill)=none} the mode: 'none', 'corner', 'corner-bottom', 'fill' (optional, default 'none') (optional) * @param {duration=10i} the reload-time in duration-format or defined as an item that retriggers a refresh (optional, default '10i') * @param {image=} the path/url to a default image that is shown on error and startup * @param {text(true,false)=false} set to 'true' in order to load the image by php script, e.g. if image URL contains credentials (optional, default = 'false') * * @see misc/fundamentals#Duration-Format */ {% macro image(id, src, mode, refresh, default_img, localize) %} <img {% if not id is empty %} id="{{ uid(page, id) }}"{% endif %} data-widget="multimedia.image" alt="multimedia.image" {% if mode == 'corner' %} class="ui-corner-all multimediaimage" {% elseif mode == 'corner-bottom' %} class="ui-corner-bottom multimediaimage" {% elseif mode == 'fill' %} style="width: 100%" class="multimediaimage" {% endif %} data-item="{% if '/' not in src and '\\' not in src %}{{ src }}{% endif %}{% if refresh|first not in ['0','1','2','3','4','5','6','7','8','9'] and refresh %}, {{ refresh }}{% endif %}" data-url="{% if '/' in src or '\\' in src %}{% if localize == 'true' %}./lib/multimedia/camimage.php?url={% endif %}{{ src }}{% endif %}" {% if refresh|first in ['0','1','2','3','4','5','6','7','8','9'] or not refresh %}data-repeat="{{ refresh|default('10i') }}"{% endif %} stopTimer="false" src="{{ default_img|default('pages/base/pics/trans.png') }}" onerror="javascript:this.src='{{ default_img|default('pages/base/pics/trans.png') }}'" /> {% endmacro %}
- ab jetzt steht im Widget der Parameter "localize" zur Verfügung. Wird der auf 'true' gesetzt, verwendet das Widget das php-Skript zum Laden des Bildes. Als URL wird wie vorher die reine URL das Bildes angegeben:
Code:{{ multimedia.image('cam01', 'http://admin:xxxxxxxx@192.168.yyy.yyy/record/current.jpg', 'fill', '5s', '', 'true') }}
Schöne Feiertage!
Gruß
Wolfram
Kommentar
-
Hallo Wolfram
Da ist noch ein Fehler in
Code:{{ multimedia.image('cam01', 'http://admin:xxxxxxxx@192.168.yyy.yyy/record/current.jpg', 'fill', '5s', '', 'true') }}
Dann funktioniert das zumindest mit dem Firefox. Mit Chrome und Edge aber wieder nicht.
Gehe ich zurück auf die vorherige Version klappt es wieder.
Was natürlich problemlos funktioniert: camimage.php in einen neuen Ordner ./lib/multimedia/ verschieben und den Pfad im Aufruf anpassen.
Code:{{ multimedia.image('cam01', './lib/multimedia/camimage.php?cam=haustuer&url=http://admin:xxxxxxxxx@192.168.yyy.yyy/record/current.jpg', 'fill', '5s') }}
Kommentar
Kommentar