Proper Way to Remove Thumbnail Links In Gallery

Instead of using 2 separate functions to grab the attachment you can use the same function, and then add the URL in separately using wp_get_attachment_url, making the logic much clearer, and reducing the amount of work needed:

e.g.

$image = wp_get_attachment_image( $id, $size, false );

// if it's set to not show the image link
if(isset($attr['link']) && ('none' == $attr['link']) ){
    // then just show the image
    echo $image;
} else {
    // else show the image wrapped in a link
    $link = wp_get_attachment_url($id);
    echo "<a href=\"$link\">$image</a>";
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)