PHP Classes

PHP Imagemap Class: Generate clickable image maps in HTML

Recommend this page to a friend!
  Info   View files Documentation   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-12-17 (20 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 62 This week: 7All time: 10,352 This week: 9Up
Version License PHP version Categories
php-image-map-class 1.0GNU General Publi...5HTML, PHP 5, Graphics
Description 

Author

This package can generate clickable image maps in HTML.

It takes the coordinates of areas of an image and associates URLs of pages that the user browser will be redirected to when the users click on the image areas.

The package also takes the URL of an image and generates HTML to display the image with map areas that the users can click to lead their browsers to the pages associated with the clickable area.

Innovation Award
PHP Programming Innovation award nominee
December 2023
Nominee
Vote
Image maps are HTML page elements defining areas in images that the users may click.

Each area in a image may have an associated page URL. When the user clicks on a site painting with an image map, the browser is redirected to a page with the URL associated with the area that the user clicked.

This package can generate image maps that associate areas of an image with pages that the user may visit when the user clicks on those image areas.

Manuel Lemos
Picture of Eric Jumba
  Performance   Level  
Name: Eric Jumba <contact>
Classes: 3 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Recommendations

Recommendation for a PHP class to generate imagemap
Generate an imagemap by drawing rectangles over an image

Documentation

Simple PHP Imagemap Class

This is a simple PHP class that generates an HTML image map. An image map allows you to define clickable areas on an image, and when users click on those areas, they are redirected to specific URLs. In this example, I'll create a basic class that allows you to add rectangular clickable areas to an image.

The ImageMapGenerator class has two methods:

addArea: Adds a rectangular clickable area to the image map. You provide the coordinates (x1, y1, x2, y2) of the top-left and bottom-right corners of the rectangle, along with the URL to which the user should be redirected when clicking the area.

generateMap: Generates the HTML code for the image map. It takes the file path of the image as a parameter and returns the complete HTML code that includes the image and the map with defined areas.

// Example usage:

$imageMapGenerator = new ImageMapGenerator();
$imageMapGenerator->addArea(10, 20, 100, 80, 'https://example.com/link1');
$imageMapGenerator->addArea(120, 30, 180, 90, 'https://example.com/link2');

$imagePath = 'path/to/your/image.jpg';
$imageMapHtml = $imageMapGenerator->generateMap($imagePath);

echo $imageMapHtml;

  Files folder image Files  
File Role Description
Plain text file imagemap.class.php Class Class source
Accessible without login Plain text file readme.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:7
All time:10,352
This week:9Up