icamys / php-sitemap-generator

A simple PHP sitemap generator.
MIT License
168 stars 65 forks source link

Update GoogleImageExtension.php #54

Closed mofthedev closed 1 year ago

mofthedev commented 1 year ago

Added the support for multiple image:loc infos per page.

To use only one image for a page:

// // add image
$extensions = [
    'google_image' => ['loc' => 'https://www.example.com/thumbs/1.jpg']
];

To use multiple images for a page:

// add multiple images
$extensions = [
    'google_image' =>   [
                            ['loc' => 'https://www.example.com/thumbs/1.jpg'],
                            ['loc' => 'https://www.example.com/thumbs/2.jpg'],
                            ['loc' => 'https://www.example.com/thumbs/3.jpg']
                        ]

];

The code can be shortened by array_is_list() function. Because it is not supported by PHP<=7, we better use the classic way to determine if the data given is an assoc or a numeric array.

icamys commented 1 year ago

@mofthedev Thank you for your great work! Closing this PR in favor of a more complete #62