Skip to content
Public Ticket #1872

missing alt description for images in gallery

Conversation thread

PenciDesign replied

Staff Reply

Hi,

Ok. When you done, let's send that infor for me and I will take it a look.

Best Regards,

PenciDesign

mc_kugelfang replied

Customer Reply

i'll have to push everything on a server first - currently only working on xampp

PenciDesign replied

Staff Reply

Hi,

Please send me your admin url and admin account ( username and password  ) in a private reply. I will take it a look on this.

Best Regards,

PenciDesign

mc_kugelfang replied

Customer Reply

Hi & thanks for your answer,

I think it partly did the job, yet, now I have 2 different issues resulting from this (see images):

1. The justified gallery adds the alt-description as caption (this shouldn't be the case though - I haven't added a caption) -> image1

2. The grid gallery adds medium images instead of the correct ones -> image2+image3

I did a little tinkering now myself and changed a few lines (below, marked with /*TODO2*/).:

--------------------------------------------------------------

if( $posts ) {
foreach ( $posts as $imagePost ) {
$caption = '';
if( $imagePost->post_excerpt ):
$caption = $imagePost->post_excerpt;
endif;
if( $imagePost->_wp_attachment_image_alt ):
    $alt = $imagePost->_wp_attachment_image_alt;
endif; /*TODO2*/
$get_full = wp_get_attachment_image_src( $imagePost->ID, 'full' );
$get_masonry = wp_get_attachment_image_src( $imagePost->ID, 'penci-masonry-thumb' );

\

if( $type == 'single-slider' ):
$output .= '<figure>';
$get_masonry = wp_get_attachment_image_src( $imagePost->ID, 'penci-full-thumb' );
endif;

\

if( $type == 'masonry grid' ):
$get_masonry = wp_get_attachment_image_src( $imagePost->ID, 'penci-thumb' );
endif;

\

/*$output .= '<a class="item-gallery-'. $type .'" href="'. $get_full[0] .'" title="'. $caption .'" data-rel="penci-gallery-image-content">';*/ /*TODO*/
$output .= '<a class="item-gallery-'. $type .'" href="'. $get_full[0] .'" title="'. $caption .'">';

\

if( $type == 'masonry' || $type == 'masonry grid' ):
$output .= '<div class="inner-item-masonry-gallery">';
endif;

\

if( $type == 'single-slider' ){
$output .= '<img class="owl-lazy" data-src="'. $get_masonry[0] .'" alt="'. $alt .'">'; /*TODO2*/
/*$output .= '<img class="owl-lazy" data-src="'. $get_masonry[0] .'" alt="">';*/
} else {
$output .= '<img src="'. $get_masonry[0] .'" alt="'. $alt .'">'; /*TODO2*/
/*$output .= '<img src="'. $get_masonry[0] .'" alt="">';*/
/*$output .= wp_get_attachment_image( $imagePost->ID, 'penci-masonry-thumb' );*/
}

\

if( $type == 'masonry' || $type == 'masonry grid' ):
$output .= '</div>';
endif;

\

$output .= '</a>';

\

if( $type == 'single-slider' ):
if( $caption ):
$output .= '<p class="penci-single-gallery-captions">'. $caption .'</p>';
endif;
$output .= '</figure>';
endif;

\

}
}

--------------------------------------------------------------

This fixes issue 2 (medium images instead of the correct ones -> see image 4), 

yet I still strangely have the alt-description as caption...(issue 1 still exists...)

Any ideas?

mc_kugelfang replied

Customer Reply

thanks, i will take a look

PenciDesign replied

Staff Reply

Hi,

Yeah, I understand it now.

To fixed it, please replace this code like on this image to this code:

\
$output .= wp_get_attachment_image( $imagePost->ID, 'penci-masonry-thumb' );

Best Regards,

PenciDesign

mc_kugelfang replied

Customer Reply

No, I mean a missing alt-description. I just deactivated all plugins non-related to this theme to make sure that there is no interference.

\

1. I added an alt-description on all images. (already did before) (see image)

\

2. added a gallery

\

3. checking the image of a gallery out: no set alt-attribute (see image)

PenciDesign replied

Staff Reply

Hi,

If you mean set a caption of that images, you need to set it via caption box like on image I sent you.

Best Regards,

PenciDesign

mc_kugelfang replied

Customer Reply

Hi and thanks for your answer.

A missing alt-description doesnt seem to be the issue though, as I have added alt descriptions to all images beforehand in the media library. (See both images: alt desc. on image added w/o gallery gets shown (2.jpg), image in gallery doesnt... yet, there is an alt-attribute (but empty) in the img-tag (1.jpg)). The "= 'alt desc'" after the alt-attribute is missing on all gallery images.

PenciDesign replied

Staff Reply

Hi,

By default, wordpress doesn't auto create alt for images. You need to add it for yourself.

Check more on this image.

Best Regards,

PenciDesign

mc_kugelfang started the conversation

Conversation Start

Hi guys! Thnks again for your help with another ticket :)

\

I'm still working on a relaunch of my site and using this theme on a copy of the site via XAMPP to get the redesign done and just switch everything afterwards…

\

Yet, I got 1 issue though:

\

I noticed that the alt descriptions of the images seem to be missing when I have added a gallery into a post (see image)

I’d appreciate any help :)

Want to join this conversation or access attachments? Sign in first.