Changeset 3438971
- Timestamp:
- 01/13/2026 08:02:56 PM (3 weeks ago)
- Location:
- alt-text-imagerr-ai
- Files:
-
- 10 edited
- 1 copied
-
tags/1.6 (copied) (copied from alt-text-imagerr-ai/trunk)
-
tags/1.6/imagerr.php (modified) (3 diffs)
-
tags/1.6/readme.txt (modified) (2 diffs)
-
tags/1.6/src/Async/BackgroundProcess.php (modified) (1 diff)
-
tags/1.6/src/Meta.php (modified) (4 diffs)
-
tags/1.6/templates/support.php (modified) (2 diffs)
-
trunk/imagerr.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Async/BackgroundProcess.php (modified) (1 diff)
-
trunk/src/Meta.php (modified) (4 diffs)
-
trunk/templates/support.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
alt-text-imagerr-ai/tags/1.6/imagerr.php
r3434623 r3438971 3 3 * Plugin Name: AI Image Alt Text Generator – Imagerr AI 4 4 * Description: Generate alt text, titles, descriptions, and captions for your images automatically with AI. 5 * Version: 1. 55 * Version: 1.6 6 6 * Text Domain: alt-text-imagerr-ai 7 7 * Domain Path: /languages … … 38 38 */ 39 39 class Imagerr { 40 /** 41 * Maximum log file size in bytes before rotation. 42 * Default: 5 MB (5 * 1024 * 1024 bytes) 43 * 44 * @var int 45 */ 46 const LOG_FILE_MAX_SIZE = 5 * 1024 * 1024; // 5 MB 47 40 48 /** 41 49 * Meta class. … … 1020 1028 1021 1029 /** 1030 * Rotate log file content if it exceeds the size limit. 1031 * Keeps only the most recent content, removing older entries. 1032 * 1033 * @return void 1034 */ 1035 public static function rotate_log_if_needed() { 1036 $log_file = self::get_debug_log_path(); 1037 $max_size = self::LOG_FILE_MAX_SIZE; 1038 $keep_size = intval( $max_size * 0.8 ); // Keep last 80% (leaves 20% headroom) 1039 1040 // Check if log file exists and exceeds the limit 1041 if ( ! file_exists( $log_file ) || filesize( $log_file ) < $max_size ) { 1042 return; 1043 } 1044 1045 $file_size = filesize( $log_file ); 1046 $bytes_to_remove = $file_size - $keep_size; 1047 1048 // Open file for reading 1049 $handle = @fopen( $log_file, 'r' ); 1050 if ( ! $handle ) { 1051 return; 1052 } 1053 1054 // Seek to the position where we want to start keeping content 1055 // We'll keep everything from this position to the end 1056 fseek( $handle, $bytes_to_remove ); 1057 1058 // Read forward to find the first complete line (don't cut mid-line) 1059 // Read a chunk to find the next newline 1060 $chunk = fread( $handle, 1024 ); 1061 if ( $chunk === false ) { 1062 fclose( $handle ); 1063 return; 1064 } 1065 1066 // Find first newline in the chunk 1067 $newline_pos = strpos( $chunk, "\n" ); 1068 if ( $newline_pos === false ) { 1069 // No newline found in first chunk, try reading more 1070 $chunk = fread( $handle, 8192 ); 1071 $newline_pos = strpos( $chunk, "\n" ); 1072 } 1073 1074 if ( $newline_pos !== false ) { 1075 // Found newline, adjust position to start after it 1076 $keep_from_position = $bytes_to_remove + $newline_pos + 1; 1077 } else { 1078 // No newline found (unlikely but handle it), start from current position 1079 $keep_from_position = $bytes_to_remove; 1080 } 1081 1082 fclose( $handle ); 1083 1084 // Read the content we want to keep (from keep_from_position to end) 1085 $handle = @fopen( $log_file, 'r' ); 1086 if ( ! $handle ) { 1087 return; 1088 } 1089 1090 fseek( $handle, $keep_from_position ); 1091 $content_to_keep = stream_get_contents( $handle ); 1092 fclose( $handle ); 1093 1094 if ( $content_to_keep === false ) { 1095 return; 1096 } 1097 1098 // Write the kept content back to the file (truncate and write) 1099 $handle = @fopen( $log_file, 'w' ); 1100 if ( $handle ) { 1101 fwrite( $handle, $content_to_keep ); 1102 fclose( $handle ); 1103 } 1104 } 1105 1106 /** 1022 1107 * Download logs file 1023 1108 */ -
alt-text-imagerr-ai/tags/1.6/readme.txt
r3434623 r3438971 5 5 Requires PHP: 5.2 6 6 Requires at least: 4.6 7 Stable tag: 1. 57 Stable tag: 1.6 8 8 Tested up to: 6.9 9 9 License: GPLv2 or later … … 71 71 72 72 == Changelog == 73 = 1.6 = 74 * Added support for palette type images 75 * Updated texts in the support section 76 * Added a file-size limit to the debug logs file 77 73 78 = 1.5 = 74 79 * Added bulk generator action to the bulk actions dropdown on the Media Library page -
alt-text-imagerr-ai/tags/1.6/src/Async/BackgroundProcess.php
r3434623 r3438971 115 115 116 116 if ( $debug_enabled ) { 117 // Rotate log if it exceeds size limit 118 \Imagerr::rotate_log_if_needed(); 119 117 120 $log_file = \Imagerr::get_debug_log_path(); 118 121 $timestamp = date( 'Y-m-d H:i:s' ); -
alt-text-imagerr-ai/tags/1.6/src/Meta.php
r3434623 r3438971 32 32 33 33 if ( $debug_enabled ) { 34 // Rotate log if it exceeds size limit 35 \Imagerr::rotate_log_if_needed(); 36 34 37 $timestamp = date( 'Y-m-d H:i:s' ); 35 38 $log_message = "[$timestamp] $message"; … … 535 538 536 539 /** 537 * Try to convert image to WebP format and create temporary file. Otherwise, return original image path.540 * Try to convert image to WebP format and create temporary file. Otherwise, return false. 538 541 * 539 542 * @param string $image_path The path to the original image. … … 584 587 return false; 585 588 } 589 590 // Check if it's a palette image and convert it 591 if (!imageistruecolor($image_resource)) { 592 imagepalettetotruecolor($image_resource); 593 } 586 594 587 595 // Create temporary file for WebP image with .webp extension … … 616 624 return $temp_webp; 617 625 618 } catch ( \ Exception$e ) {619 $this->log( "-- E xceptionduring WebP conversion: " . $e->getMessage() );626 } catch ( \Throwable $e ) { 627 $this->log( "-- Error during WebP conversion: " . $e->getMessage() ); 620 628 return false; 621 629 } -
alt-text-imagerr-ai/tags/1.6/templates/support.php
r3434623 r3438971 48 48 <h2><?php esc_html_e( 'Documentation', 'alt-text-imagerr-ai' ); ?></h2> 49 49 <p><?php esc_html_e( 'Documentation on how to use the Imagerr AI WordPress plugin can be found on our website by clicking the button below:', 'alt-text-imagerr-ai' ); ?></p> 50 <p><?php esc_html_e( '(Available in English only - you can use a browser translator)', 'alt-text-imagerr-ai' ); ?></p> 50 51 <p> 51 52 <a href="https://imagerr.ai/documentation-wp/" target="_blank" class="button-primary"> … … 59 60 <h2><?php esc_html_e( 'Imagerr AI Support', 'alt-text-imagerr-ai' ); ?></h2> 60 61 <p><?php esc_html_e( 'To contact the Imagerr AI support, please check the Contact Us page on our website:', 'alt-text-imagerr-ai' ); ?></p> 62 <p><?php esc_html_e( '(NOTE: Support is provided in English only. Please contact us in English for the fastest response.)', 'alt-text-imagerr-ai' ); ?></p> 61 63 <p> 62 64 <a href="https://imagerr.ai/contact/" target="_blank" class="button-primary"> -
alt-text-imagerr-ai/trunk/imagerr.php
r3434623 r3438971 3 3 * Plugin Name: AI Image Alt Text Generator – Imagerr AI 4 4 * Description: Generate alt text, titles, descriptions, and captions for your images automatically with AI. 5 * Version: 1. 55 * Version: 1.6 6 6 * Text Domain: alt-text-imagerr-ai 7 7 * Domain Path: /languages … … 38 38 */ 39 39 class Imagerr { 40 /** 41 * Maximum log file size in bytes before rotation. 42 * Default: 5 MB (5 * 1024 * 1024 bytes) 43 * 44 * @var int 45 */ 46 const LOG_FILE_MAX_SIZE = 5 * 1024 * 1024; // 5 MB 47 40 48 /** 41 49 * Meta class. … … 1020 1028 1021 1029 /** 1030 * Rotate log file content if it exceeds the size limit. 1031 * Keeps only the most recent content, removing older entries. 1032 * 1033 * @return void 1034 */ 1035 public static function rotate_log_if_needed() { 1036 $log_file = self::get_debug_log_path(); 1037 $max_size = self::LOG_FILE_MAX_SIZE; 1038 $keep_size = intval( $max_size * 0.8 ); // Keep last 80% (leaves 20% headroom) 1039 1040 // Check if log file exists and exceeds the limit 1041 if ( ! file_exists( $log_file ) || filesize( $log_file ) < $max_size ) { 1042 return; 1043 } 1044 1045 $file_size = filesize( $log_file ); 1046 $bytes_to_remove = $file_size - $keep_size; 1047 1048 // Open file for reading 1049 $handle = @fopen( $log_file, 'r' ); 1050 if ( ! $handle ) { 1051 return; 1052 } 1053 1054 // Seek to the position where we want to start keeping content 1055 // We'll keep everything from this position to the end 1056 fseek( $handle, $bytes_to_remove ); 1057 1058 // Read forward to find the first complete line (don't cut mid-line) 1059 // Read a chunk to find the next newline 1060 $chunk = fread( $handle, 1024 ); 1061 if ( $chunk === false ) { 1062 fclose( $handle ); 1063 return; 1064 } 1065 1066 // Find first newline in the chunk 1067 $newline_pos = strpos( $chunk, "\n" ); 1068 if ( $newline_pos === false ) { 1069 // No newline found in first chunk, try reading more 1070 $chunk = fread( $handle, 8192 ); 1071 $newline_pos = strpos( $chunk, "\n" ); 1072 } 1073 1074 if ( $newline_pos !== false ) { 1075 // Found newline, adjust position to start after it 1076 $keep_from_position = $bytes_to_remove + $newline_pos + 1; 1077 } else { 1078 // No newline found (unlikely but handle it), start from current position 1079 $keep_from_position = $bytes_to_remove; 1080 } 1081 1082 fclose( $handle ); 1083 1084 // Read the content we want to keep (from keep_from_position to end) 1085 $handle = @fopen( $log_file, 'r' ); 1086 if ( ! $handle ) { 1087 return; 1088 } 1089 1090 fseek( $handle, $keep_from_position ); 1091 $content_to_keep = stream_get_contents( $handle ); 1092 fclose( $handle ); 1093 1094 if ( $content_to_keep === false ) { 1095 return; 1096 } 1097 1098 // Write the kept content back to the file (truncate and write) 1099 $handle = @fopen( $log_file, 'w' ); 1100 if ( $handle ) { 1101 fwrite( $handle, $content_to_keep ); 1102 fclose( $handle ); 1103 } 1104 } 1105 1106 /** 1022 1107 * Download logs file 1023 1108 */ -
alt-text-imagerr-ai/trunk/readme.txt
r3434623 r3438971 5 5 Requires PHP: 5.2 6 6 Requires at least: 4.6 7 Stable tag: 1. 57 Stable tag: 1.6 8 8 Tested up to: 6.9 9 9 License: GPLv2 or later … … 71 71 72 72 == Changelog == 73 = 1.6 = 74 * Added support for palette type images 75 * Updated texts in the support section 76 * Added a file-size limit to the debug logs file 77 73 78 = 1.5 = 74 79 * Added bulk generator action to the bulk actions dropdown on the Media Library page -
alt-text-imagerr-ai/trunk/src/Async/BackgroundProcess.php
r3434623 r3438971 115 115 116 116 if ( $debug_enabled ) { 117 // Rotate log if it exceeds size limit 118 \Imagerr::rotate_log_if_needed(); 119 117 120 $log_file = \Imagerr::get_debug_log_path(); 118 121 $timestamp = date( 'Y-m-d H:i:s' ); -
alt-text-imagerr-ai/trunk/src/Meta.php
r3434623 r3438971 32 32 33 33 if ( $debug_enabled ) { 34 // Rotate log if it exceeds size limit 35 \Imagerr::rotate_log_if_needed(); 36 34 37 $timestamp = date( 'Y-m-d H:i:s' ); 35 38 $log_message = "[$timestamp] $message"; … … 535 538 536 539 /** 537 * Try to convert image to WebP format and create temporary file. Otherwise, return original image path.540 * Try to convert image to WebP format and create temporary file. Otherwise, return false. 538 541 * 539 542 * @param string $image_path The path to the original image. … … 584 587 return false; 585 588 } 589 590 // Check if it's a palette image and convert it 591 if (!imageistruecolor($image_resource)) { 592 imagepalettetotruecolor($image_resource); 593 } 586 594 587 595 // Create temporary file for WebP image with .webp extension … … 616 624 return $temp_webp; 617 625 618 } catch ( \ Exception$e ) {619 $this->log( "-- E xceptionduring WebP conversion: " . $e->getMessage() );626 } catch ( \Throwable $e ) { 627 $this->log( "-- Error during WebP conversion: " . $e->getMessage() ); 620 628 return false; 621 629 } -
alt-text-imagerr-ai/trunk/templates/support.php
r3434623 r3438971 48 48 <h2><?php esc_html_e( 'Documentation', 'alt-text-imagerr-ai' ); ?></h2> 49 49 <p><?php esc_html_e( 'Documentation on how to use the Imagerr AI WordPress plugin can be found on our website by clicking the button below:', 'alt-text-imagerr-ai' ); ?></p> 50 <p><?php esc_html_e( '(Available in English only - you can use a browser translator)', 'alt-text-imagerr-ai' ); ?></p> 50 51 <p> 51 52 <a href="https://imagerr.ai/documentation-wp/" target="_blank" class="button-primary"> … … 59 60 <h2><?php esc_html_e( 'Imagerr AI Support', 'alt-text-imagerr-ai' ); ?></h2> 60 61 <p><?php esc_html_e( 'To contact the Imagerr AI support, please check the Contact Us page on our website:', 'alt-text-imagerr-ai' ); ?></p> 62 <p><?php esc_html_e( '(NOTE: Support is provided in English only. Please contact us in English for the fastest response.)', 'alt-text-imagerr-ai' ); ?></p> 61 63 <p> 62 64 <a href="https://imagerr.ai/contact/" target="_blank" class="button-primary">
Note: See TracChangeset
for help on using the changeset viewer.