Settings to activate the plugin'; add_settings_error('ai-image-seo-toolkit-tuning', 'no_oia_key', $err , 'error'); } else { if(!$keySet){ $notic = 'To unlock PRO features, add your License Key in Settings'; add_settings_error('ai-image-seo-toolkit-tuning', 'no_key', $notic, 'notice'); } else { if (!aiit_tuning_parameters_set()){ add_settings_error('ai-image-seo-toolkit-tuning', 'not_all', 'Complete all fields and tap "Save Changes" at the bottom', 'notice'); } } } } ?>

Tuning

An AI-powered search engine optimization WordPress plugin that streamlines image text generation by creating smart & SEO-friendly titles, ALTs, captions and descriptions.


Here you can adjust the AI's capabilities to fit your site's specific needs. Set your website type and define your target audience to align the AI Image SEO Toolkit with your content strategy, enhancing SEO relevance and.

Type of website

?
0/50

Target audience

?
0/50

Categories

?
0/20

Language

?

Set the minimum width and height in pixels for images that will undergo SEO optimization. Images smaller than these dimensions will be excluded. Images must be at least 224 pixels on the shortest side to be processed.

Min. Image Width (px)

Min. Image Height (px)


>

Text Generation Testing


Save your tuning parameters to enable testing'; } ?>
array( 'value' => sanitize_text_field($_POST['aiit_website_type']), 'error' => 'website type'), 'aiit_audience' => array( 'value' => sanitize_text_field($_POST['aiit_audience']), 'error' => 'audience'), 'aiit_categories' => array( 'value' => sanitize_text_field($_POST['aiit_categories']), 'error' => 'at least one category and make sure you click "Add Category" before saving'), 'aiit_language' => array( 'value' => sanitize_text_field($_POST['aiit_language']), 'error' => 'language'), 'aiit_min_width' => array( 'value' => sanitize_text_field($_POST['aiit_min_width']), 'error' => 'minimal width'), 'aiit_min_height' => array( 'value' => sanitize_text_field($_POST['aiit_min_height']), 'error' => 'minimal height'), ); $errorParams = ''; foreach ($parameters as $parameter) { if($parameter['value'] === ''){ if ($errorParams != ''){ $errorParams .= ', '; } $errorParams .= $parameter['error']; } } if ($errorParams === ''){ foreach ($parameters as $key => $parameter) { update_option($key, $parameter['value']); } $alt_text_prompt = $GLOBALS['aiit_prompt_settings']['alt1'] . $parameters['aiit_website_type']['value'] . $GLOBALS['aiit_prompt_settings']['alt2'] . $parameters['aiit_audience']['value'] . $GLOBALS['aiit_prompt_settings']['alt3'] . $parameters['aiit_categories']['value'] . $GLOBALS['aiit_prompt_settings']['alt4'] . $parameters['aiit_language']['value']; $title_prompt = $GLOBALS['aiit_prompt_settings']['title1'] . $parameters['aiit_language']['value'] . $GLOBALS['aiit_prompt_settings']['title2']; $title_prompt2 = $GLOBALS['aiit_prompt_settings']['title_2_1'] . $parameters['aiit_language']['value']; $caption_prompt = $GLOBALS['aiit_prompt_settings']['caption'] . $parameters['aiit_language']['value']; $description_prompt = $GLOBALS['aiit_prompt_settings']['description1'] . $parameters['aiit_website_type']['value'] . $GLOBALS['aiit_prompt_settings']['description2'] . $parameters['aiit_audience']['value'] . $GLOBALS['aiit_prompt_settings']['description3'] . $parameters['aiit_language']['value']; update_option('aiit_alt_text_prompt', $alt_text_prompt); update_option('aiit_title_prompt', $title_prompt); update_option('aiit_title_prompt2', $title_prompt2); update_option('aiit_caption_prompt', $caption_prompt); update_option('aiit_description_prompt', $description_prompt); add_settings_error('ai-image-seo-toolkit-tuning', 'success', 'Settings saved successfully.', 'updated'); } else { $message = 'Please provide ' . $errorParams; add_settings_error('ai-image-seo-toolkit-tuning', 'categories_empty', $message, 'error'); } } else { add_settings_error('ai-image-seo-toolkit-tuning', 'not_permitted', 'Invalid data provided.', 'error'); } } function aiit_provide_testing_content(){ $image_id = aiit_tuning_get_images(); ?>
Remember to click 'Save Changes' to ensure your tuning settings are saved before testing
'; $result .= aiit_provide_image_details_html($image_id[$i-1]); $result .= ''; } return $result; } function aiit_tuning_get_images() { global $wpdb; $result = array(); for ($i = 1; $i <= 3; $i++) { $image = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}aiit_tuning_images WHERE `id` = %d LIMIT 1", $i)); if ($image){ $result[] = $image->image_id; } else { $result[] = 0; } } return $result; } function aiit_start_test_optimization(){ if (!isset($_POST['security']) || !wp_verify_nonce( sanitize_text_field( wp_unslash($_POST['security'])), 'aiit_tuning_nonce')) { wp_send_json_error('Permission check failed'); } $image_id = aiit_tuning_get_images(); $error = ""; foreach ( $image_id as $image ) { if ($image !== 0){ $processedOK = aiit_generate_alt_text($image, -2); //error_log('aiit_start_test_optimization, processedOK?: '. print_r($processedOK, true)); if ($processedOK['status'] == "nok") { if ($error != ""){ $error .= "
"; } $error .= $processedOK['error']; } } } $result = aiit_tuning_get_all_details($image_id); if ($error != ""){ $error_html = '

Processing error:
'; $error_html .= $error; $error_html .= '

'; $result .= $error_html; } wp_send_json_success(array( 'html'=> $result, )); } // Image file upload function aiit_upload_tuning_image_callback() { if (!isset($_POST['security']) || !wp_verify_nonce( sanitize_text_field( wp_unslash($_POST['security'])), 'aiit_tuning_nonce')) { wp_send_json_error('Permission check failed'); } $plhId = sanitize_text_field($_POST['plhId']); if (isset($_FILES['image'])) { $file = $_FILES['image']; if ($file['error'] !== UPLOAD_ERR_OK) { wp_send_json_error('File upload error: ' . $file['error']); return; } require_once(ABSPATH . 'wp-admin/includes/image.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/media.php'); $min_width = get_option('aiit_min_width'); $min_height = get_option('aiit_min_height'); // Check image dimensions $image_info = getimagesize($file['tmp_name']); if ($image_info === false) { wp_send_json_error('The uploaded file is not a valid image.'); return; } $width = $image_info[0]; $height = $image_info[1]; if ($width < $min_width || $height < $min_height) { wp_send_json_error('Image dimensions are smaller than defined minimal values'); } $attachment_id = media_handle_upload('image', 0); if (is_wp_error($attachment_id)) { wp_send_json_error(array('message' => 'Error uploading the image.')); } else { global $wpdb; $table_name = $wpdb->prefix . 'aiit_tuning_images'; $existing_record = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}aiit_tuning_images WHERE id = %d", $plhId)); if ($existing_record) { $wpdb->delete($table_name, array('id' => $plhId), array('%d')); } $wpdb->insert($table_name, array('id' => $plhId, 'image_id' => $attachment_id), array('%d', '%d')); $generate = get_option('aiit_generate_on_upload'); if($generate != "on"){ aiit_generate_alt_text($attachment_id, -2); } // Image uploaded successfully $image_url = wp_get_attachment_url($attachment_id); $freshImageData = aiit_provide_image_details_html($attachment_id); wp_send_json_success(array( 'url' => $image_url, 'html'=> $freshImageData, )); } } else { // No file was uploaded wp_send_json_error('No image file received.'); } } function aiit_provide_image_details_html($image_id) { $keySet = aiit_k_valid(); if ($image_id > 0){ if ($keySet){ $title = get_the_title($image_id); $description = get_post_field('post_content', $image_id); $caption = get_post_field('post_excerpt', $image_id); } $alt = get_post_meta($image_id, '_wp_attachment_image_alt', true); } else { $title = ""; $description = ""; $alt = ""; $caption = ""; } $freshImageData = ''; if ($keySet){ $freshImageData .= '

Title

'. $title . '

'; } $freshImageData .= '

Alt Text

' . $alt . '

'; if ($keySet){ $freshImageData .= '

Caption

' . $caption . '

Description

' . $description . '

'; } return $freshImageData; }