Deutsch · Русский · English · Español · Français
A JavaScript viewer lets visitors explore a spherical panorama directly on your site. They can drag with a mouse or finger, zoom in, and enter fullscreen. This example uses Pannellum and an equirectangular JPEG.
Interactive example
Open the panorama and drag to look around. Use + and − to zoom.
Prepare the panorama
A full sphere covers 360° horizontally and 180° vertically. Use an equirectangular image with a 2:1 aspect ratio, such as 4096 × 2048 pixels. A cropped panorama needs different field-of-view settings.
Export a web-sized copy and remove EXIF location data if needed. If a single JPEG is too large, use Pannellum’s multiresolution mode to load only the tiles needed for the current view.
Add the viewer to an HTML page
Save this example as panorama.html and place
panorama.jpg beside it. Copy pannellum.css and
pannellum.js from the same Pannellum release into the
pannellum folder. Serve the files over HTTPS.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>360° spherical panorama</title>
<link rel="stylesheet" href="./pannellum/pannellum.css">
<script src="./pannellum/pannellum.js" defer></script>
<style>
body { margin: 0; }
#panorama {
width: 100%;
height: clamp(280px, 60vh, 640px);
background: #10243a;
}
</style>
</head>
<body>
<div id="panorama" aria-label="Interactive 360° spherical panorama"></div>
<p><a href="./panorama.jpg">Open the panorama as a JPEG</a></p>
<script>
document.addEventListener('DOMContentLoaded', () => {
if (!window.pannellum) return;
pannellum.viewer('panorama', {
type: 'equirectangular',
panorama: './panorama.jpg',
autoLoad: false,
showFullscreenCtrl: true,
mouseZoom: false,
yaw: 0,
pitch: 0,
hfov: 100,
strings: { loadButtonLabel: 'Load panorama' }
});
});
</script>
</body>
</html>
The viewer waits for a click before loading the full JPEG. Set
yaw, pitch and hfov to choose the
starting view. Use preview to display a smaller image
before the full panorama loads.
Embed the viewer in WordPress
Add a Custom HTML block. Replace the example path with the URL of your viewer page. The iframe keeps the viewer’s styles and JavaScript separate from the WordPress theme.
<iframe
src="/panorama.html"
title="Interactive 360° spherical panorama"
loading="lazy"
allowfullscreen
style="display:block;width:100%;height:clamp(360px,70vh,720px);border:0">
</iframe>
If WordPress removes the iframe when saving, check the permissions for custom HTML or use an approved embed block. If the image and viewer are on different domains, configure the image server to permit requests from the viewer’s origin via CORS.
Test before publishing
- Open the page without signing in on desktop and mobile.
- Test loading, dragging, zoom and fullscreen.
- Check that the viewer fits within a narrow screen.
- Provide a direct JPEG link for browsers that cannot render the panorama.