+ /**
+ * Get images urls from the srcset image attribute.
+ *
+ * @param Crawler $imagesCrawler
+ *
+ * @return array An array of urls
+ */
+ protected function getSrcsetUrls(Crawler $imagesCrawler)
+ {
+ $urls = [];
+ $iterator = $imagesCrawler
+ ->getIterator();
+ while ($iterator->valid()) {
+ $srcsetAttribute = $iterator->current()->getAttribute('srcset');
+ if ('' !== $srcsetAttribute) {
+ $srcset = array_map('trim', explode(',', $srcsetAttribute));
+ $srcsetUrls = array_map(function ($src) {
+ return explode(' ', $src)[0];
+ }, $srcset);
+ $urls = array_merge($srcsetUrls, $urls);
+ }
+ $iterator->next();
+ }
+
+ return $urls;
+ }
+