Plugin Directory

Changeset 3438971


Ignore:
Timestamp:
01/13/2026 08:02:56 PM (3 weeks ago)
Author:
andrejdivi
Message:

Update to version 1.6 from GitHub

Location:
alt-text-imagerr-ai
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • alt-text-imagerr-ai/tags/1.6/imagerr.php

    r3434623 r3438971  
    33 * Plugin Name: AI Image Alt Text Generator – Imagerr AI
    44 * Description: Generate alt text, titles, descriptions, and captions for your images automatically with AI.
    5  * Version: 1.5
     5 * Version: 1.6
    66 * Text Domain: alt-text-imagerr-ai
    77 * Domain Path: /languages
     
    3838 */
    3939class 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
    4048    /**
    4149     * Meta class.
     
    10201028
    10211029    /**
     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    /**
    10221107     * Download logs file
    10231108     */
  • alt-text-imagerr-ai/tags/1.6/readme.txt

    r3434623 r3438971  
    55Requires PHP: 5.2
    66Requires at least: 4.6
    7 Stable tag: 1.5
     7Stable tag: 1.6
    88Tested up to: 6.9
    99License: GPLv2 or later
     
    7171
    7272== 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
    7378= 1.5 =
    7479* 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  
    115115       
    116116        if ( $debug_enabled ) {
     117            // Rotate log if it exceeds size limit
     118            \Imagerr::rotate_log_if_needed();
     119           
    117120            $log_file = \Imagerr::get_debug_log_path();
    118121            $timestamp = date( 'Y-m-d H:i:s' );
  • alt-text-imagerr-ai/tags/1.6/src/Meta.php

    r3434623 r3438971  
    3232       
    3333        if ( $debug_enabled ) {
     34            // Rotate log if it exceeds size limit
     35            \Imagerr::rotate_log_if_needed();
     36           
    3437            $timestamp = date( 'Y-m-d H:i:s' );
    3538            $log_message = "[$timestamp] $message";
     
    535538
    536539    /**
    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.
    538541     *
    539542     * @param string $image_path The path to the original image.
     
    584587                return false;
    585588            }
     589
     590            // Check if it's a palette image and convert it
     591            if (!imageistruecolor($image_resource)) {
     592                imagepalettetotruecolor($image_resource);
     593            }
    586594           
    587595            // Create temporary file for WebP image with .webp extension
     
    616624            return $temp_webp;
    617625
    618         } catch ( \Exception $e ) {
    619             $this->log( "-- Exception during WebP conversion: " . $e->getMessage() );
     626        } catch ( \Throwable $e ) {
     627            $this->log( "-- Error during WebP conversion: " . $e->getMessage() );
    620628            return false;
    621629        }
  • alt-text-imagerr-ai/tags/1.6/templates/support.php

    r3434623 r3438971  
    4848        <h2><?php esc_html_e( 'Documentation', 'alt-text-imagerr-ai' ); ?></h2>
    4949        <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>
    5051        <p>
    5152            <a href="https://imagerr.ai/documentation-wp/" target="_blank" class="button-primary">
     
    5960        <h2><?php esc_html_e( 'Imagerr AI Support', 'alt-text-imagerr-ai' ); ?></h2>
    6061        <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>
    6163        <p>
    6264            <a href="https://imagerr.ai/contact/" target="_blank" class="button-primary">
  • alt-text-imagerr-ai/trunk/imagerr.php

    r3434623 r3438971  
    33 * Plugin Name: AI Image Alt Text Generator – Imagerr AI
    44 * Description: Generate alt text, titles, descriptions, and captions for your images automatically with AI.
    5  * Version: 1.5
     5 * Version: 1.6
    66 * Text Domain: alt-text-imagerr-ai
    77 * Domain Path: /languages
     
    3838 */
    3939class 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
    4048    /**
    4149     * Meta class.
     
    10201028
    10211029    /**
     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    /**
    10221107     * Download logs file
    10231108     */
  • alt-text-imagerr-ai/trunk/readme.txt

    r3434623 r3438971  
    55Requires PHP: 5.2
    66Requires at least: 4.6
    7 Stable tag: 1.5
     7Stable tag: 1.6
    88Tested up to: 6.9
    99License: GPLv2 or later
     
    7171
    7272== 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
    7378= 1.5 =
    7479* 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  
    115115       
    116116        if ( $debug_enabled ) {
     117            // Rotate log if it exceeds size limit
     118            \Imagerr::rotate_log_if_needed();
     119           
    117120            $log_file = \Imagerr::get_debug_log_path();
    118121            $timestamp = date( 'Y-m-d H:i:s' );
  • alt-text-imagerr-ai/trunk/src/Meta.php

    r3434623 r3438971  
    3232       
    3333        if ( $debug_enabled ) {
     34            // Rotate log if it exceeds size limit
     35            \Imagerr::rotate_log_if_needed();
     36           
    3437            $timestamp = date( 'Y-m-d H:i:s' );
    3538            $log_message = "[$timestamp] $message";
     
    535538
    536539    /**
    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.
    538541     *
    539542     * @param string $image_path The path to the original image.
     
    584587                return false;
    585588            }
     589
     590            // Check if it's a palette image and convert it
     591            if (!imageistruecolor($image_resource)) {
     592                imagepalettetotruecolor($image_resource);
     593            }
    586594           
    587595            // Create temporary file for WebP image with .webp extension
     
    616624            return $temp_webp;
    617625
    618         } catch ( \Exception $e ) {
    619             $this->log( "-- Exception during WebP conversion: " . $e->getMessage() );
     626        } catch ( \Throwable $e ) {
     627            $this->log( "-- Error during WebP conversion: " . $e->getMessage() );
    620628            return false;
    621629        }
  • alt-text-imagerr-ai/trunk/templates/support.php

    r3434623 r3438971  
    4848        <h2><?php esc_html_e( 'Documentation', 'alt-text-imagerr-ai' ); ?></h2>
    4949        <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>
    5051        <p>
    5152            <a href="https://imagerr.ai/documentation-wp/" target="_blank" class="button-primary">
     
    5960        <h2><?php esc_html_e( 'Imagerr AI Support', 'alt-text-imagerr-ai' ); ?></h2>
    6061        <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>
    6163        <p>
    6264            <a href="https://imagerr.ai/contact/" target="_blank" class="button-primary">
Note: See TracChangeset for help on using the changeset viewer.