Browse Source

Rename to scan_images()

Rename for more meaningful
pull/698/head
danpros 1 year ago
parent
commit
8d58741b88
2 changed files with 9 additions and 8 deletions
  1. +3
    -2
      system/admin/admin.php
  2. +6
    -6
      system/includes/functions.php

+ 3
- 2
system/admin/admin.php View File

@ -1627,15 +1627,16 @@ function reorder_subpages($subpages = null)
rebuilt_cache(); rebuilt_cache();
} }
// Return image gallery in pager.
// Return image gallery in pager. // Return image gallery in pager.
function image_gallery($images, $page = 1, $perpage = 0) function image_gallery($images, $page = 1, $perpage = 0)
{ {
if (empty($images)) { if (empty($images)) {
$images = get_gallery();
$images = scan_images();
} }
$pagination = has_pagination(count($images), $perpage, $page);
$tmp = ''; $tmp = '';
$images = array_slice($images, ($page - 1) * $perpage, $perpage); $images = array_slice($images, ($page - 1) * $perpage, $perpage);
$pagination = has_pagination(count($images), $perpage, $page);
$tmp .= '<div class="cover-container">'; $tmp .= '<div class="cover-container">';
foreach ($images as $index => $v) { foreach ($images as $index => $v) {
$tmp .= '<div class="cover-item"><img loading="lazy" class="img-thumbnail the-img" src="' . site_url() . $v['dirname'] . '/'. $v['basename'].'"></div>'; $tmp .= '<div class="cover-item"><img loading="lazy" class="img-thumbnail the-img" src="' . site_url() . $v['dirname'] . '/'. $v['basename'].'"></div>';


+ 6
- 6
system/includes/functions.php View File

@ -222,19 +222,19 @@ function get_zip_files()
} }
// Get images in content/images folder // Get images in content/images folder
function get_gallery() {
static $_gallery = array();
if (empty($_gallery)) {
function scan_images() {
static $_images = array();
if (empty($_images)) {
$tmp = array(); $tmp = array();
$tmp = glob('content/images/*', GLOB_NOSORT); $tmp = glob('content/images/*', GLOB_NOSORT);
if (is_array($tmp)) { if (is_array($tmp)) {
foreach ($tmp as $file) { foreach ($tmp as $file) {
$_gallery[] = pathinfo($file);
$_images[] = pathinfo($file);
} }
} }
usort($_gallery, "sortfile_d");
usort($_images, "sortfile_d");
} }
return $_gallery;
return $_images;
} }
// usort function. Sort by filename. // usort function. Sort by filename.


Loading…
Cancel
Save