Support » Plugin: DCO Comment Attachment » Link clicking thumbnail to media page instead of full size of image

  • Resolved nourijp

    (@nourijp)


    Hello. I have been using this plugin for a while and it really is wonderful, but from the beginning for my use case, I had something in mind. I thought it might be added as a feature eventually, but it hasn’t yet. So I thought to either suggest it as a feature or ask help on how to achieve this:

    I want to link clicking thumbnail to media page instead of full size of image, so when someone views the thumbnail in the comment section and clicks on it, they will be taken to the media section.

    • This topic was modified 6 months, 1 week ago by nourijp.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Denis Yanchevskiy

    (@denisco)

    Hello @nourijp,

    Try the following steps:
    0. Back up your site. You can also contact your hosting support for it.
    1. Update the DCO Comment Attachment plugin to version 2.1.1 if you haven’t already.
    2. Go to the Settings > DCO Comment Attachment section and uncheck the “Link thumbnail to full-size image?” option if it’s enabled and save changes.
    3. Add the following code to functions.php of your active theme or use a Code Snippets plugin.

    function custom_dco_ca_get_attachment_preview_image( $attachment_content, $attachment_id, $thumbnail_size ) {
    	if ( ! is_admin() ) {
    		$url = get_attachment_link( $attachment_id );
    		$img = wp_get_attachment_image( $attachment_id, $thumbnail_size );
    		$attachment_content = '<p class="dco-attachment dco-image-attachment"><a href="' . esc_url( $url ) . '">' . $img . '</a></p>';
    	}
    	
    	return $attachment_content;
    }
    
    add_filter('dco_ca_get_attachment_preview_image', 'custom_dco_ca_get_attachment_preview_image', 10, 3);
    Thread Starter nourijp

    (@nourijp)

    Wow! You are a legend!

    Thank you so much! I wish I had asked you earlier! Very cool!

    Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Link clicking thumbnail to media page instead of full size of image’ is closed to new replies.