-
Notifications
You must be signed in to change notification settings - Fork 3
/
admin_regenerate_images.php
63 lines (43 loc) · 2.34 KB
/
admin_regenerate_images.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
include("system_header.php");
admin_only();
$regenerate_thumbnails_log = '';
$total_files_generated = 0;
foreach($categories_array as $category_title=>$images_array){
$working_directory = "files/".$category_title;
// remove thumbnail of category
@unlink($working_directory."/thumbnail.jpg");
foreach($categories_array[$category_title] as $image_file){
$regenerate_thumbnails_log .= "\nLoading ".$working_directory."/".$image_file.".jpg";
// scale down the "display" image
@unlink($working_directory."/".$image_file."_small.jpg");
if($imagemagick_installed){
resize_in_limits($working_directory."/".$image_file.".jpg", $working_directory."/".$image_file."_small.jpg", $settings_photo_width, $settings_photo_height);
} else {
gd_resize_in_limits($working_directory."/".$image_file.".jpg", $working_directory."/".$image_file."_small.jpg", $settings_photo_width, $settings_photo_height);
}
// save the thumb image
@unlink($working_directory."/".$image_file."_thumb.jpg");
if($imagemagick_installed){
crop_image($working_directory."/".$image_file.".jpg", $working_directory."/".$image_file."_thumb.jpg", $settings_thumbnail_width, $settings_thumbnail_height);
} else {
gd_crop_image($working_directory."/".$image_file.".jpg", $working_directory."/".$image_file."_thumb.jpg", $settings_thumbnail_width, $settings_thumbnail_height);
}
// make this image category thumbnail unless one already exists
if(!file_exists($working_directory."/thumbnail.jpg")){
copy($working_directory."/".$image_file."_thumb.jpg", $working_directory."/thumbnail.jpg");
}
$total_files_generated++;
}
}
$regenerate_thumbnails_log = trim($regenerate_thumbnails_log);
// header("Location: ".$gallery_url."/admin-categories?message=category added&message_type=success");
// exit;
?>
<?php include("header.php");?>
<h1>Regenerate tumbnails</h1>
<p class="breadcrumb"><a href="/">home</a> > <a href="<?php echo $gallery_url;?>">gallery</a> > <a href="<?php echo $gallery_url;?>/admin">admin</a> > regenerate thumbnails</p>
<h2>Log</h2>
<p><?php echo nl2br(htmlentities($regenerate_thumbnails_log, ENT_QUOTES, "UTF-8"));?></p>
<p style="color:#EA0000;">Generated thumbnails and display images for <?php echo $total_files_generated;?> images.</p>
<?php include("footer.php");?>