Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @samot80,

    Pretty sure that this is the reason why you’re seeing these notices:

    Link text (and alternate text for images, when used as links)

    Your popular post thumbnails don’t have alternate text (or alt) assigned to them. The attribute is empty, hence the accessibility issue.

    Take this one for example:

    <li>
        <a href="https://www.tachido.mx/chicas-palidas/" target="_self">
            <img src="https://www.tachido.mx/wp-content/uploads/wordpress-popular-posts/167633-featured-380x250.jpg" srcset="https://www.tachido.mx/wp-content/uploads/wordpress-popular-posts/167633-featured-380x250.jpg, https://www.tachido.mx/wp-content/uploads/wordpress-popular-posts/[email protected] 1.5x" alt="" class="wpp-thumbnail wpp_featured wpp_cached_thumb" loading="lazy" width="380" height="250">
        </a>
        <a href="https://www.tachido.mx/chicas-palidas/" class="wpp-post-title" target="_self">Chicas pálidas</a>
    </li>

    (That’s the post at the top of the list).

    You need to make sure that your images have their alt attribute filled with descriptive text when used with links, as the error message describes, so people with visual disabilities can “see” them.

    Screenshot of an image with its ALT field filled with content

    See Edit Media for more details.

    • This reply was modified 2 years, 10 months ago by Hector Cabrera. Reason: Added screenshot
    • This reply was modified 2 years, 10 months ago by Hector Cabrera. Reason: Added link to the Edit Media documentation page
    Thread Starter Samot80

    (@samot80)

    Is it possible, if the alt””, the plugin places the name of the post in the featured image? For example: Post name = that’s amazing. If featured image.alt=”” then alt”that’s amazing” Or something like that?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hola @samot80,

    Voy a asumir que hablas espa?ol porque el sitio web está en espa?ol también ??

    Mira, el plugin llena el atributo ALT de la imagen de forma automática con la data que está en Biblioteca de Medios (Media > Biblioteca). Si el atributo de la imagen está vacío en la biblioteca pues naturalmente la imagen no tendrá ALT en el front-end.

    Si tienes muchas imágenes en la biblioteca -y por el tipo de sitio web que tienes supongo que es así- llenar todos esos campos manualmente va a tomar mucho tiempo. Afortunadamente, el plugin provee un filtro que te puede ayudar con eso, wpp_thumbnail_alt_attribute. Y casualmente el ejemplo que está en la documentación hace exactamente lo que necesitas: asigna el título del post como atributo ALT para la imagen.

    Si tienes alguna pregunta avísame.

    Plugin Author Hector Cabrera

    (@hcabrera)

    … aunque releyendo tu último comentario quizás sea mejor cambiar el código a ésto:

    /**
     * Modifies WPP thumbnails' ALT attribute.
     *
     * @param  string  $alt_attribute
     * @param  int     $post_id
     * @return string
     */
    function my_wpp_thumbnail_alt_attribute($alt_attribute, $post_id) {
        // The ALT attribute is missing
        if ( '' == $alt_attribute ) {
            // Let's use the post title as ALT attribute
            // for our thumbnail
            $alt_attribute = get_post_field('post_title', $post_id);
        }
    
        return $alt_attribute;
    }
    add_filter('wpp_thumbnail_alt_attribute', 'my_wpp_thumbnail_alt_attribute', 10, 2);
    Thread Starter Samot80

    (@samot80)

    Muchas gracias Héctor, como bien dices, son bastantes imágenes y complicado colocar ese atributo. Si fuera yo el único que subo contenido sería más fácil. Una última duda, el código se agrega en functions.php ?

    Por cierto, el plugin es estupendo y llevo a?os utilizándolo.
    Saludos

    Plugin Author Hector Cabrera

    (@hcabrera)

    Una última duda, el código se agrega en functions.php ?

    Sip, va en el archivo functions.php de tu tema actual.

    También puedes utilizar un plugin como Code Snippets para agregar ese código a tu sitio web sin tener que tocar functions.php.

    Personalmente prefiero la primera opción pero no está de más tener otras alternativas.

    Por cierto, el plugin es estupendo y llevo a?os utilizándolo.

    ?Gracias por el cumplido!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Links do not have a discernible name’ is closed to new replies.