Skip to content

Instantly share code, notes, and snippets.

@ircykk
Last active June 26, 2019 18:29
Show Gist options
  • Save ircykk/7886c391259137673650f8a9a245cabe to your computer and use it in GitHub Desktop.
Save ircykk/7886c391259137673650f8a9a245cabe to your computer and use it in GitHub Desktop.
Modyfikacja kolejności zdjęć
public function injectImages($images)
{
foreach ($images as $imagePath => $imageUrl) {
$this->add('images', [['url' => $imageUrl]]);
}
// ten kod dodajemy
if (count($this->structure['images']) > 1) {
$tmp = $this->structure['images'][0];
$this->structure['images'][0] = $this->structure['images'][1];
$this->structure['images'][1] = $tmp;
}
foreach ($this->structure['description']['sections'] as $section) {
foreach ($section->items as $key => $item) {
if (!empty($item->url)) {
if (isset($images[$item->url])) {
$item->url = $images[$item->url];
} else {
// No image, limit? Delete section item
unset($section->items[$key]);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment