Skip to main content
Tweeted twitter.com/#!/StackWordPress/status/96513817093226496
edited title
Link
Aces
  • 441
  • 1
  • 4
  • 13

Change image link: wp_get_attachment_link

added 6 characters in body
Source Link
Aces
  • 441
  • 1
  • 4
  • 13

Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template:

$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
$attachments = get_posts($args);
if ($attachments) {
    foreach ( $attachments as $attachment ) {
    echo wp_get_attachment_link( $attachment->ID , array(150,150) ); 
    }
}

I can add a filter to add class or rel but I can't find anyway to alter the default (as originally uploaded) full size of the image linked to in the template .... The above works fine with colorbox (not plugin) to create a lightbox, but if a user uploads a very large image (ie: 4000x4000+ pixels), it loadsthe link will load too slowly and I don't want the public to be able to download a print quality image from the lightbox..

Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template:

$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
$attachments = get_posts($args);
if ($attachments) {
    foreach ( $attachments as $attachment ) {
    echo wp_get_attachment_link( $attachment->ID , array(150,150) ); 
    }
}

I can add a filter to add class or rel but I can't find anyway to alter the default size of the image linked to in the template .... The above works fine with colorbox (not plugin) to create a lightbox, but if a user uploads a very large image (ie: 4000x4000+ pixels), it loads too slowly and I don't want the public to be able to download a print quality image from the lightbox..

Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template:

$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
$attachments = get_posts($args);
if ($attachments) {
    foreach ( $attachments as $attachment ) {
    echo wp_get_attachment_link( $attachment->ID , array(150,150) ); 
    }
}

I can add a filter to add class or rel but I can't find anyway to alter the default (as originally uploaded) full size image linked to in the template .... The above works fine with colorbox (not plugin) to create a lightbox, but if a user uploads a very large image (ie: 4000x4000+ pixels), the link will load too slowly and I don't want the public to be able to download a print quality image from the lightbox..

added 6 characters in body
Source Link
Aces
  • 441
  • 1
  • 4
  • 13

Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template:

$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
$attachments = get_posts($args);
if ($attachments) {
    foreach ( $attachments as $attachment ) {
    echo wp_get_attachment_link( $attachment->ID , array(150,150) ); 
    }
}

I can add a filter to add class or rel but I can't find anyway to alter the default size of the image linked to in the template .... The above works fine with colorbox (not plugin) to create a lightbox, but if a user uploads a very large image (ie: 4000x4000+ pixels), it loads too slowly and I don't want themthe public to be able to download a print quality image from the lightbox..

Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template:

$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
$attachments = get_posts($args);
if ($attachments) {
    foreach ( $attachments as $attachment ) {
    echo wp_get_attachment_link( $attachment->ID , array(150,150) ); 
    }
}

I can add a filter to add class or rel but I can't find anyway to alter the default size of the image linked to in the template .... The above works fine with colorbox (not plugin) to create a lightbox, but if a user uploads a very large image (ie: 4000x4000+ pixels), it loads too slowly and I don't want them to be able to download a print quality image from the lightbox..

Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template:

$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
$attachments = get_posts($args);
if ($attachments) {
    foreach ( $attachments as $attachment ) {
    echo wp_get_attachment_link( $attachment->ID , array(150,150) ); 
    }
}

I can add a filter to add class or rel but I can't find anyway to alter the default size of the image linked to in the template .... The above works fine with colorbox (not plugin) to create a lightbox, but if a user uploads a very large image (ie: 4000x4000+ pixels), it loads too slowly and I don't want the public to be able to download a print quality image from the lightbox..

edited body
Source Link
Aces
  • 441
  • 1
  • 4
  • 13
Loading
Source Link
Aces
  • 441
  • 1
  • 4
  • 13
Loading