<?php
/**
* Extract images and other information from 'For Your Garden' plant pages.
*
*/
function extract_for_your_garden(string $file_path): array {
$source = file_get_contents($file_path);
$phtml = new \Taeluf\PHTML($source);
$img_urls = $phtml->xpath('//img[@class="cmp-image__image"]');
$plant_img = $img_urls[0]->src;
// REMOVE everything after ?qlt=100 , because the image urls fail to load with the extra query params (no idea why)
$pos = strpos($plant_img, '&ts=');
$link = substr($plant_img, 0, $pos);
return [
'img_url' => $link,
];
}