next()) { // Continue if the files has been processed or does not exist if (isset($images[$imageFiles->path]) || !file_exists(System::getContainer()->getParameter('kernel.project_dir') . '/' . $imageFiles->path)) { continue; } // Single files if ($imageFiles->type == 'file') { $objFile = new File($imageFiles->path); if (!$objFile->isImage) { continue; } // Add the image $images[$imageFiles->path] = $imageFiles->current(); } // Folders else { $objSubfiles = FilesModel::findByPid($imageFiles->uuid, array('order' => 'name')); if ($objSubfiles === null) { continue; } while ($objSubfiles->next()) { // Skip subfolders if ($objSubfiles->type == 'folder') { continue; } $objFile = new File($objSubfiles->path); if (!$objFile->isImage) { continue; } // Add the image $images[$objSubfiles->path] = $objSubfiles->current(); } } } if ($strOrder !== null) { $images = ArrayUtil::sortByOrderField($images, $strOrder); } $images = array_values($images); // Offset images if ($intOffset > 0) { $images = \array_slice($images, ($intOffset < count($images) ? $intOffset : count($images))); } // Limit number of images if ($intLimit > 0) { $images = \array_slice($images, 0, $intLimit); } // Build figures of images foreach ($images as $image) { $figure = $figureBuilder ->fromFilesModel($image) ->build(); $arrImageFigures[] = $figure; } } return count ($arrImageFigures) === 1 && $intLimit === 1 ? array_shift($arrImageFigures) : $arrImageFigures; } public function getImageDataUrl($path) { $type = pathinfo($path, PATHINFO_EXTENSION); $data = file_get_contents($path); return 'data:image/' . $type . ';base64,' . base64_encode($data); } }