PHP Classes

PHP Imagemap Class: Generate clickable image maps in HTML

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-12-17 (10 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 87 All time: 9,999 This week: 38Up
Version License PHP version Categories
php-image-map-class 1.0.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
Number 3
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 is available for providing paid consulting. Contact Eric Jumba .
Classes: 8 packages by
Country: United States United States
Age: 35
All time rank: 3832499 in United States United States
Week rank: 216 Up24 in United States United States Up
Innovation award
Innovation award
Nominee: 4x

Winner: 2x

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 (2)  
File Role Description
Plain text file imagemap.class.php Class Class source
Accessible without login Plain text file readme.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:87
This week:0
All time:9,999
This week:38Up