Alt text and titles on portfolio images and links – Waving portfolio

I am working on a project to help optimize the content of a site for search engines and all of the images and links within this plugin are not pulling the alt text and titles for the images and anchors within the portfolio.

I have looked through the waving-portfolio.php file to see where this issue might be originating and the lines that add the images and links for the modals and lightbox do not pull alt text or titles.

Read More

I am looking for a quick fix to add some lines of php to that file so that the hundreds of images and links have alt text and titles attributed to them.

Here is what that section of the file looks like currently on the site I am working on.

if($width != 0){
$image_code = '<img src="'.$image[0].'" style="width:'.$width.'px" />';
}else
{
$image_code = '<img src="'.$image[0].'" style="height:'.$height.'px" >';
}

So how do I add something to those lines of code to make it pull the alt text and title of the image from the media library?

https://wordpress.org/plugins/waving-portfolio/

Related posts

2 comments

  1.     $title = $alt = get_the_title();
        if($width != 0){
        $image_code = '<img title="'.$title.'" alt="'.$alt.'" src="'.$image[0].'" style="width:'.$width.'px" />';
        }else
        {
        $image_code = '<img title="'.$title.'" alt="'.$alt.'" src="'.$image[0].'" style="height:'.$height.'px" >';
        }
    
  2. I fixed this lack of SEO problem in Waving Portfolio and submitted an update just now, all you have to do is remove and install your plugin again.

    The fix added “img” meta information for all of the internal gallery as well.

    For general benefits here is the code I have added to fetch the “alt” & “title” for an attachment (In our case a featured image). In Line 300 inside of “waving-portfolio.php” I added these lines of code to get the desired information:

    $image = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID() ), 'single-post-thumbnail' );
    
    // Get the featured image ID
    $post_thumbnail_id = get_post_thumbnail_id(get_the_ID());     
    // Retrieve the title of the image
    $title = get_the_title( $post_thumbnail_id );
    // Retrieve the alternate text of the image
    $alt = get_post_meta($post_thumbnail_id, '_wp_attachment_image_alt', true);
    

    You can see the effect in the Demo page, although I haven’t given any meaningful titles for the images so far, but soon I will do 🙂

    Thanks

Comments are closed.