Created
October 25, 2023 08:32
-
-
Save wp-seopress/ef96f0f045a8ea9010e9b2a07d38c46a to your computer and use it in GitHub Desktop.
Filter the prompt sent to OpenAI to generate alt text for images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sp_ai_openai_alt_text($prompt_alt_text, $post_id) { | |
$language = 'English'; | |
$image_src = wp_get_attachment_image_src($post_id, 'full'); | |
$prompt_alt_text = sprintf(__('Write in less than 10 words an alternative text to improve accessibility and SEO, in this language %1$s, for this image URL: %2$s.', 'wp-seopress-pro'), esc_attr($language), esc_html($image_src[0])); | |
return $prompt_alt_text; | |
} | |
add_filter( 'seopress_ai_openai_alt_text', 'sp_ai_openai_alt_text', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment