lemaur/laravel-image-sitemap

Sitemap with images

Fund package maintenance!
lemaur

1.0.1 2022-01-23 14:03 UTC

This package is auto-updated.

Last update: 2024-10-29 06:41:38 UTC


README

Latest Version on Packagist Total Downloads License GitHub Tests Action Status GitHub Code Style Action Status GitHub Sponsors Trees

This package can generate a sitemap with images according to Google Specifications.

It's basically built on top of Spatie's laravel-sitemap. The reason why I create it, it's because Spatie doesn't plan to add this functionality to his own package (see here for more info).

Support Me

Hey folks,

Do you like this package? Do you find it useful and it fits well in your project?

I am glad to help you, and I would be so grateful if you considered supporting my work.

You can even choose 😃:

Installation

You can install the package via composer:

composer require lemaur/laravel-image-sitemap

You can publish the config file with:

php artisan vendor:publish --provider="Lemaur\Sitemap\SitemapServiceProvider" --tag="laravel_image_sitemap-config"

Usage

You can refer directly to Spatie's laravel-sitemap documentation to which I've added the possibility to include images. See the example below.

use Carbon\Carbon;
use Lemaur\Sitemap\Sitemap;
use Lemaur\Sitemap\Tags\Image;
use Lemaur\Sitemap\Tags\Url;

Sitemap::create()

    ->add(Url::create('/home')
        ->setLastModificationDate(Carbon::yesterday())
        ->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
        ->setPriority(0.1)
        ->addImage('/url/to/images.jpg')
        ->addImage(
            Image::create('/url/to/another-image.jpg')
                ->setTitle('Image Title')
                ->setCaption('Image Alt Text')
                ->setGeoLocation('Image Geo Location')
                ->setLicense('https://url/to/the/license')
        ))

   ->add(...)

   ->writeToFile($path);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.