forked from ZwiiCMS-Team/ZwiiCMS
11504 Génération de la capture d'écran du site
This commit is contained in:
parent
fe07622042
commit
4716733c34
@ -257,8 +257,18 @@ class config extends common {
|
|||||||
$site = 'https://zwiicms.fr/'; } else {
|
$site = 'https://zwiicms.fr/'; } else {
|
||||||
$site = helper::baseUrl(false); }
|
$site = helper::baseUrl(false); }
|
||||||
|
|
||||||
$success= false;
|
// Succès de la'opération par défaut
|
||||||
$googlePagespeedData = helper::getUrlContents('https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url='. $site .'&screenshot=true');
|
$success = false;
|
||||||
|
|
||||||
|
// Tente de connecter 5 fois l'API Google
|
||||||
|
for ($i=0; $i < 5 ; $i++) {
|
||||||
|
$googlePagespeedData = helper::getUrlContents('https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url='. $site .'&screenshot=true');
|
||||||
|
if ($googlePagespeedData !== false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Traitement des données reçues valides.
|
||||||
if ($googlePagespeedData !== false) {
|
if ($googlePagespeedData !== false) {
|
||||||
$googlePagespeedData = json_decode($googlePagespeedData, true);
|
$googlePagespeedData = json_decode($googlePagespeedData, true);
|
||||||
$data = str_replace('_','/',$googlePagespeedData['lighthouseResult']['audits']['final-screenshot']['details']['data']);
|
$data = str_replace('_','/',$googlePagespeedData['lighthouseResult']['audits']['final-screenshot']['details']['data']);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
<?php echo template::button('socialMetaImage', [
|
<?php echo template::button('socialMetaImage', [
|
||||||
'href' => helper::baseUrl() . 'config/configMetaImage',
|
'href' => helper::baseUrl() . 'config/configMetaImage',
|
||||||
'value' => 'Générer une capture Open Graph'
|
'value' => 'Générer une capture Open Graph'
|
||||||
|
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user