Last active
June 26, 2019 18:29
-
-
Save ircykk/7886c391259137673650f8a9a245cabe to your computer and use it in GitHub Desktop.
Modyfikacja kolejności zdjęć
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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