' . esc_html__("Which method do you want to use to generate the alt text for the images?", 'auto-alt-text') . '
';
$typology = get_option(Constants::AATXT_OPTION_FIELD_TYPOLOGY);
?>
' . esc_html__('Notice', 'auto-alt-text') . ': ' .
esc_html__('This plugin leverages the new "gpt-4-vision-preview" model from OpenAI to identify the content of the image.', 'auto-alt-text') . ' ' .
esc_html__('As the name suggests, this model is still in a preview stage and OpenAI states:', 'auto-alt-text') . ' "
This is a preview model version and not suited yet for production traffic".
' .
esc_html__('Therefore, it is necessary to select a fallback model in case gpt-4-preview fails.', 'auto-alt-text') . '
' .
esc_html__('The fallback models are not able to read the content of the image but will rely exclusively on the name of the image file, guessing its content.', 'auto-alt-text') . '
' .
esc_html__('In case of errors, it is still possible to find the specific reason stated on the', 'auto-alt-text') . '
' . esc_html__('error log page', 'auto-alt-text') . '.' .
'
';
echo '';
echo '
';
echo '
' . esc_html__("Enter a specific and detailed prompt according to your needs.", 'auto-alt-text') . '
';
$defaultPrompt = sprintf(esc_html__("Act like an SEO expert and write an alt text of up to 125 characters for this image.", 'auto-alt-text'), Constants::AATXT_IMAGE_URL_TAG);
$prompt = get_option(Constants::AATXT_OPTION_FIELD_PROMPT_OPENAI) ?: $defaultPrompt;
echo '
';
echo '
';
echo '';
echo '
';
echo '
' . esc_html__("Choose the alternative OpenAI model you want to use to generate the alt text when the gpt-4-vision-preview model fails.", 'auto-alt-text') . '
';
$modelSaved = get_option(Constants::AATXT_OPTION_FIELD_FALLBACK_MODEL_OPENAI);
?>
';
echo '
';
echo '
';
echo '
' . esc_html__("Enter a specific and detailed prompt according to your needs.", 'auto-alt-text') . '
';
$defaultPrompt = sprintf(esc_html__("Act like an SEO expert and write an English alt text for this image %s, using a maximum of 125 characters. Just return the text without any additional comments.", 'auto-alt-text'), Constants::AATXT_IMAGE_URL_TAG);
$fallbackPrompt = get_option(Constants::AATXT_OPTION_FIELD_FALLBACK_PROMPT_OPENAI) ?: $defaultPrompt;
echo '
';
echo '
';
echo '
' . esc_html__("Fill out the following fields to leverage Azure's computer vision services to generate the Alt texts.", 'auto-alt-text') . '
';
echo '
';
echo '
';
echo '
' . esc_html__("Enter the API key for the Computer Vision service of your Azure account.", 'auto-alt-text') . '
';
$apiKey = get_option(Constants::AATXT_OPTION_FIELD_API_KEY_AZURE_COMPUTER_VISION);
echo '
';
echo '
';
echo '
';
echo '
';
echo '
' . esc_html__("Enter the endpoint of the Computer Vision service.", 'auto-alt-text') . ' (es. https://computer-vision-france-central.cognitiveservices.azure.com/)
';
$endpoint = get_option(Constants::AATXT_OPTION_FIELD_ENDPOINT_AZURE_COMPUTER_VISION);
echo '
';
echo '
';
echo '
' .
'' . esc_html__('The default alt text language is English.', 'auto-alt-text') . '
' .
esc_html__('If you want to translate into another language, enter the following data necessary for the translation API to work.', 'auto-alt-text') . ' ' .
esc_html__('After saving the changes you can select the desired language.', 'auto-alt-text') .
'
';
echo '
';
echo '
';
echo '
' . esc_html__("Enter your API key for the Azure Translate Instance service.", 'auto-alt-text') . '
';
$translationApiKey = get_option(Constants::AATXT_OPTION_FIELD_API_KEY_AZURE_TRANSLATE_INSTANCE);
echo '
';
echo '
';
echo '
';
echo '
';
echo '
' . esc_html__("Enter the endpoint of the Translate Instance service", 'auto-alt-text') . ' (es. https://api.cognitive.microsofttranslator.com/)
';
$translationEndpoint = get_option(Constants::AATXT_OPTION_FIELD_ENDPOINT_AZURE_TRANSLATE_INSTANCE);
echo '
';
echo '
';
echo '
';
echo '
';
echo '
' . esc_html__("Enter the region of the Azure Translate Instance service.", 'auto-alt-text') . ' (es. westeurope)
';
$translationRegion = get_option(Constants::AATXT_OPTION_FIELD_REGION_AZURE_TRANSLATE_INSTANCE);
echo '
';
echo '
';
if ($translationApiKey && $translationEndpoint && $translationRegion):
echo '
';
echo '
';
echo '
' . esc_html__("Select the language in which the alt text should be written.", 'auto-alt-text') . '
';
$currentLanguage = get_option(Constants::AATXT_OPTION_FIELD_LANGUAGE_AZURE_TRANSLATE_INSTANCE);
try {
$supportedLanguages = (AzureTranslator::make())->supportedLanguages();
} catch (AzureTranslateInstanceException $e) {
$supportedLanguages = [
"en" => [
"name" => "English",
"nativeName" => "English",
"dir" => "ltr",
]
];
echo '
' . esc_html($e->getMessage()) . '
';
}
?>
';
endif;
submit_button();
?>
decrypt($apiKey);
}
/**
* @return string
*/
public static function apiKeyAzureComputerVision(): string
{
$apiKey = get_option(Constants::AATXT_OPTION_FIELD_API_KEY_AZURE_COMPUTER_VISION);
return (Encryption::make())->decrypt($apiKey);
}
/**
* @return string
*/
public static function endpointAzureComputerVision(): string
{
return get_option(Constants::AATXT_OPTION_FIELD_ENDPOINT_AZURE_COMPUTER_VISION);
}
/**
* @return string
*/
public static function apiKeyAzureTranslateInstance(): string
{
$apiKey = get_option(Constants::AATXT_OPTION_FIELD_API_KEY_AZURE_TRANSLATE_INSTANCE);
return (Encryption::make())->decrypt($apiKey);
}
/**
* @return string
*/
public static function endpointAzureTranslateInstance(): string
{
return get_option(Constants::AATXT_OPTION_FIELD_ENDPOINT_AZURE_TRANSLATE_INSTANCE);
}
/**
* @return string
*/
public static function regionAzureTranslateInstance(): string
{
return get_option(Constants::AATXT_OPTION_FIELD_REGION_AZURE_TRANSLATE_INSTANCE);
}
/**
* @return string
*/
public static function languageAzureTranslateInstance(): string
{
return get_option(Constants::AATXT_OPTION_FIELD_LANGUAGE_AZURE_TRANSLATE_INSTANCE) ?: 'en';
}
/**
* @return string
*/
public static function model(): string
{
return get_option(Constants::AATXT_OPTION_FIELD_FALLBACK_MODEL_OPENAI);
}
/**
* @return string
*/
public static function fallbackPrompt(): string
{
return get_option(Constants::AATXT_OPTION_FIELD_FALLBACK_PROMPT_OPENAI);
}
public static function sanitizeUrl($input): string
{
return sanitize_url($input);
}
public static function sanitizeText($input): string
{
return sanitize_text_field($input);
}
public static function sanitizeTextArea($input): string
{
return sanitize_textarea_field($input);
}
}