[Resolved] Images Alt text

Home Forums Support Images Alt text

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1191630
    ustar

    Hi, there!

    I noticed that Alt texts and Titles for image gallery is not showing in the code of page.
    For example, i see only alt text and title in preview images when i browse on mobile screen.
    When i see page on desktop, no alt text in code.
    But, i checked all images for this product and all images witn metadata.

    Could you please help me to fix this?
    Thanks in advance.

    Regards, Sergey.

    #1191724
    David
    Staff
    Customer Support

    Hi there,

    it looks like you used Niche from the GP Site library to create the Gallery Stack.
    If so you would need to update the Appearance > Elements …. the Hook Element named Gallery Stack

    let us know if thats the case.

    #1193275
    ustar

    Hi, David!

    Shold i just push button “Update” or i need to replace the code?
    If i need use the new code, where i can find it?

    Regards, Sergey.

    #1193321
    David
    Staff
    Customer Support

    Its going to require some new code – Title attribute is fairly simple but the getting the Alt is proving to be a pain. Can you paste the code you have in your current Gallery Stack Hook here so i can take a look at the changes it will require.

    When adding code to the forum can you highlight the code and click the Code Button before submitting.

    #1193494
    ustar

    Hi, David!

    The code is original. I have changed nothing.

    <div class="woo-sumamry-wrap"><!-- open wrap -->
    	<div class="woo-gallery-stack hide-on-mobile">
    		<?php 
    		global $product;
    		
    		if ( has_post_thumbnail( $product->get_id() ) ) {
        	$attachment_ids[0] = get_post_thumbnail_id( $product->get_id() );
        	$attachment = wp_get_attachment_image_src( $attachment_ids[0], 'full' ); 
    			?>    
        	<img src="<?php echo $attachment[0] ; ?>"/>
    			<?php 
    		}
    
    		if ( method_exists( $product, 'get_gallery_image_ids' ) ) {
    			$product_image_ids = $product->get_gallery_image_ids();
    
    			foreach( $product_image_ids as $product_image_id ) {
    				$image_url = wp_get_attachment_url( $product_image_id, 'full' );
    				echo '<img src="' . $image_url . '">';
    			}
    		}
    	// Closing div found in Close Summary Wrap element
    	?>
    </div>
    #1193510
    Marcel

    Following this thread also…

    #1193615
    David
    Staff
    Customer Support

    Try this instead:

    <div class="woo-sumamry-wrap"><!-- open wrap -->
    	<div class="woo-gallery-stack hide-on-mobile">
    		<?php 
    		    global $product;
    
                // Get post product thumbnail
    		    if ( has_post_thumbnail( $product->get_id() ) ) {
        	        $attachment_ids[0] = get_post_thumbnail_id( $product->get_id() );
                    $attachment = wp_get_attachment_image_src( $attachment_ids[0], 'full' ); 
                    $attachment_alt = get_post_meta( $attachment_ids[0], '_wp_attachment_image_alt', TRUE);
                    $attachmnent_title = get_the_title( $attachment_ids[0] );
    		    ?>    
        	        <img src="<?php echo $attachment[0] ; ?>" alt="<?php echo $attachment_alt; ?>" title="<?php echo $attachmnent_title; ?>" />
    		    <?php 
    		    }
    
                // Get Product Gallery Images
    		    if ( method_exists( $product, 'get_gallery_image_ids' ) ) {
    			    $product_image_ids = $product->get_gallery_image_ids();
    
    			    foreach( $product_image_ids as $product_image_id ) {
                        $image_url = wp_get_attachment_url( $product_image_id, 'full' );
                        $image_alt = get_post_meta( $product_image_id, '_wp_attachment_image_alt', TRUE);
                        $image_title = get_the_title( $product_image_id );
                        echo '<img src="' . $image_url . '" alt="' . $image_alt . '" title="' . $image_title . '">';
    			    }
    		    }
    	    // Closing div found in Close Summary Wrap element
    	    ?>
    </div>
    #1194390
    ustar

    Hi, David!

    Alt texts on the code now! Thank you very much!

    Regards, Sergey.

    #1194391
    ustar

    )

    #1194411
    Marcel

    Thank you @ustar for the thread, thank you @David for the solution!

    #1194524
    David
    Staff
    Customer Support

    Awesome – ill update Niche when i get a moment.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.