Compare commits

...

3 Commits

Author SHA1 Message Date
quenousimporte 9a53ed1da3 Merge branch 'main' of https://git.ouvaton.coop/quenousimporte/presse 2024-06-18 09:46:22 +02:00
quenousimporte 74ad25f7e3 le monde add experimental image only mode 2024-06-14 12:21:54 +02:00
quenousimporte 2c7c35cb09 refactor 2024-06-14 12:20:55 +02:00
1 changed files with 22 additions and 8 deletions

View File

@ -53,6 +53,16 @@
return $temp_img_path;
}
function inner_html($node)
{
$innerHTML = '';
foreach ($node->childNodes as $childNode)
{
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
}
return $innerHTML;
}
date_default_timezone_set('Europe/Paris');
$date = (new DateTime('today'))->format('Ymd');
@ -62,6 +72,8 @@
// parameters hardcoded for now
$includeimages = false;
$includepages = true;
$imagesonly = false;
$imagesize = $imagesonly ? "XLARGE" : "MEDIUM";
$url = $_POST['lmurl'];
@ -112,14 +124,17 @@
}))[0];
$pageid = $pageobj->PublicationPageID;
$path = lm_download_image($url, 'Preview-MEDIUM-', $pageid);
$epub->AddPage('<img style="width: 100%" src="' . $path . '">', false, 'Page ' . $page, true);
$path = lm_download_image($url, 'Preview-' . $imagesize . '-', $pageid);
// Add page 1 as cover
if ($page == 1)
{
// cover
$epub->AddImage($path, 'image/jpeg', true);
}
else
{
$epub->AddPage('<img style="width: 100%" src="' . $path . '">', false, 'Page ' . $page, true);
}
}
$articlebody = array_filter($article->ContentItem, function($item) { return $item->ContentType == 'text/xml'; });
@ -151,15 +166,14 @@
$pagecontent .= '<p><img style="width: 100%" src="' . $path . '"></p>';
}
}
$pagecontent .= $articlebody->HtmlText;
// debug
// echo '<pre style="white-space: pre-wrap;">' . $pagecontent . '<br>----------------------</pre>';
if (!$imagesonly)
{
$epub->AddPage($pagecontent, false, strip_tags($articlebody->Title), true);
}
}
}
write_epub($epub);
}