Author Topic: Inserting jpg image problem  (Read 1243 times)

0 Members and 1 Guest are viewing this topic.

Offline mickopla

  • Forecaster
  • *****
  • Posts: 358
    • Waterford City Weather
Inserting jpg image problem
« on: August 10, 2021, 01:34:18 PM »
Hi
I'm trying to add this image http://waterfordweather.ddns.net:8080/images/live.jpg

To this page https://waterfordcityweather.com/wxwebcam.php

I have tried the normal <img src= method but when i load the page no image appears.

Any help here would be great.

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Inserting jpg image problem
« Reply #1 on: August 10, 2021, 01:48:43 PM »
Hi,
While not centred like the two other images above it, it seems to be displaying fine and updating.


Enjoy,
Paul

Offline mickopla

  • Forecaster
  • *****
  • Posts: 358
    • Waterford City Weather
Re: Inserting jpg image problem
« Reply #2 on: August 10, 2021, 01:52:17 PM »
Hi,
While not centred like the two other images above it, it seems to be displaying fine and updating.


Enjoy,
Paul

That is a different webcam pointing in the same direction. I want to discontinue the image at the bottom and replace it with the better quality one here http://waterfordweather.ddns.net:8080/images/live.jpg

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Inserting jpg image problem
« Reply #3 on: August 10, 2021, 02:16:19 PM »
Your existing cam is referenced in TWO places.

1/ In the holding <element>

2/ In the immediately following 'refresh' javascript.

Make sure you amend the url in both places.

As an aside ... the holding element (and the script) has three <center> but no closures ?
Imagine what you will KNOW tomorrow !

Offline mickopla

  • Forecaster
  • *****
  • Posts: 358
    • Waterford City Weather
Re: Inserting jpg image problem
« Reply #4 on: August 10, 2021, 02:31:51 PM »
Your existing cam is referenced in TWO places.

1/ In the holding <element>

2/ In the immediately following 'refresh' javascript.

Make sure you amend the url in both places.

As an aside ... the holding element (and the script) has three <center> but no closures ?
Thanks for the reply

Yes you are right that the cam is listed in two places when it doesn't need to be. How would you clean up the lack of closures and three center issue?

When the urls are amended with http://waterfordweather.ddns.net:8080/images/live.jpg i just get a blank image. It won't display on the page for some reason. Thats my main issue.

Offline davidefa

  • Forecaster
  • *****
  • Posts: 436
Re: Inserting jpg image problem
« Reply #5 on: August 10, 2021, 06:10:29 PM »
By default browsers do not allow 'mixed content'  ( 'http' resources in 'https' pages ).
You can enable mixed content in your browser ( even if it is a security risk ) but visitors ( who have mixed content disabled ) will not visualize the page correctly

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9278
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Inserting jpg image problem
« Reply #6 on: August 10, 2021, 06:12:44 PM »
The browser is causing the issue.  When you main page is loaded using HTTPS, then all other parts (CSS, images, etc) must also be loaded by HTTPS -- an HTTP only image will not display (due to the mixed secure/non-secure content).  You'll need to get a SSL certificate for waterfordweather.ddns.net in order to display the image, and it will have to be https://waterfordweather.ddns.net:8080/images/live.jpg  to work on your page.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Inserting jpg image problem
« Reply #7 on: August 10, 2021, 06:20:43 PM »
... and when you've done that ...

Html cleaned up / modified.

Script rewritten to update all images with the classname 'refresh'  ;)
Code: [Select]
<div align="center"> <!-- cams container -->
<p> Webcam Waterford City Suburbs Looking East</p>
<p> Credit to TII For Kilmacthomas/Dungarvan Road Cams</p>
<div align="center">
<img class="lb-image refresh" src="https://cdn.mtcc.ie/static/cctv/0286.jpg" style="display: inline;">
<img class="lb-image refresh" src="https://cdn.mtcc.ie/static/cctv/0330.jpg" style="display: inline;">

<p> My fantastic webcam ...</p>
<img src="http://waterfordweather.ddns.net:8080/images/live.jpg" class="refresh" style= " /* width: 640px; height; 480px; */ border: 2px solid black">

<SCRIPT language="JavaScript" type="text/javascript">
<!--
 var t = 10; // interval in seconds
 var x = document.getElementsByClassName("refresh");  
 var cam = setInterval( function() {
tmp = new Date();
tmp = "?"+tmp.getTime()
for(y = 0; y < x.length; y++) {
z = x[y].src.split('?');
x[y].src = z[0]+tmp;
}
}, t * 1000);
// -->
</SCRIPT>
</div>
</div> <!-- END cams container -->


<footer>
Imagine what you will KNOW tomorrow !

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Inserting jpg image problem
« Reply #8 on: August 10, 2021, 11:08:27 PM »
OK ....

Some down and dirty code that should work  :shock:

Edit: Useless code suggestion removed !
« Last Edit: August 11, 2021, 10:07:18 AM by the beteljuice »
Imagine what you will KNOW tomorrow !

Offline mickopla

  • Forecaster
  • *****
  • Posts: 358
    • Waterford City Weather
Re: Inserting jpg image problem
« Reply #9 on: August 11, 2021, 03:05:55 AM »
Thanks and much appreciated. Will get down to using the code later.

Offline mickopla

  • Forecaster
  • *****
  • Posts: 358
    • Waterford City Weather
Re: Inserting jpg image problem
« Reply #10 on: August 11, 2021, 04:34:22 AM »
OK ....

Some down and dirty code that should work  :shock:

html / javascript:
Code: [Select]
<div align="center"> <!-- cams container -->
<p> Webcam Waterford City Suburbs Looking East</p>
<p> Credit to TII For Kilmacthomas/Dungarvan Road Cams</p>
<div align="center">
<img class="lb-image refresh" src="https://cdn.mtcc.ie/static/cctv/0286.jpg" style="display: inline;">
<img class="lb-image refresh" src="https://cdn.mtcc.ie/static/cctv/0330.jpg" style="display: inline;">

<p> My fantastic webcam ...</p>
<img src="webcam.jpg" class="refresh" style= " /* width: 640px; height; 480px; */ border: 2px solid black">

<?php include('camfetch.php'); ?>

<SCRIPT language="JavaScript" type="text/javascript">
<!--
 var t = 10; // interval in seconds
 var x = document.getElementsByClassName("refresh");  
 var cam = setInterval( function() {
    let response =  fetch('camfetch.php');
tmp = new Date();
tmp = "?"+tmp.getTime()
for(y = 0; y < x.length; y++) {
z = x[y].src.split('?');
x[y].src = z[0]+tmp;
}
}, t * 1000);
// -->
</SCRIPT>
</div>
</div> <!-- END cams container -->


<footer>

NEW php file - camfetch.php
Code: [Select]
<?php
ini_set
('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
$bert time();
copy("http://waterfordweather.ddns.net:8080/images/live.jpg?t=".time(),"webcam.jpg");
echo 
"<!-- cam copied -->";
exit;
?>

Note: There will be an initial update delay for your cam on page load.

Edit: Additional php include added, and php slightly modified

... I haven't posted this code  8-)

This to be implemented after i https the image which isn't https??

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Inserting jpg image problem
« Reply #11 on: August 11, 2021, 06:20:31 AM »
NO - this should work in the current circumstances !
Imagine what you will KNOW tomorrow !

Offline mickopla

  • Forecaster
  • *****
  • Posts: 358
    • Waterford City Weather
Re: Inserting jpg image problem
« Reply #12 on: August 11, 2021, 07:02:37 AM »
NO - this should work in the current circumstances !

Thats what i was thinking but it seems to be not working after updating the code..https://waterfordcityweather.com/wxwebcam.php

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Inserting jpg image problem
« Reply #13 on: August 11, 2021, 10:05:52 AM »
Hmm ...
Quote
failed to open stream: Connection refused
Didn't foresee that - I'll PM you with something naughty to try ....
Imagine what you will KNOW tomorrow !

Offline mickopla

  • Forecaster
  • *****
  • Posts: 358
    • Waterford City Weather
Re: Inserting jpg image problem
« Reply #14 on: August 11, 2021, 10:08:44 AM »
Hmm ...
Quote
failed to open stream: Connection refused
Didn't foresee that - I'll PM you with something naughty to try ....

Haha thanks in advance

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Inserting jpg image problem
« Reply #15 on: August 11, 2021, 12:14:17 PM »
General info update.

It's a 'litespeed' secure server .... the beteljuice doesn't want to get further blackhat and bows out  #-o
Imagine what you will KNOW tomorrow !

Offline ScarletWare

  • Member
  • *
  • Posts: 1
Re: Inserting jpg image problem
« Reply #16 on: February 27, 2024, 07:41:38 PM »
Integrating images can be tricky sometimes. I remember a similar situation when I was trying to embed a live webcam feed onto my website. It turned out the issue was with the image size and loading speed. Have you considered giving the image a gentle jpg compress? It might help with loading and display issues. Hope this tip helps you get that webcam up.
« Last Edit: March 01, 2024, 08:13:34 AM by ScarletWare »

 

anything