0

I am using this custom function to display image sizes on image.php (attachment page)

   function my_get_image_size_links() {

    /* If not viewing an image attachment page, return. */
    if ( !wp_attachment_is_image( get_the_ID() ) )
        return;

    /* Set up an empty array for the links. */
    $links = array();

    /* Get the intermediate image sizes and add the full size to the array. */
    $sizes = get_intermediate_image_sizes();
    $sizes[] = 'full';

    /* Loop through each of the image sizes. */
    foreach ( $sizes as $size ) {

        /* Get the image source, width, height, and whether it's intermediate. */
        $image = wp_get_attachment_image_src( get_the_ID(), $size );

        /* Add the link to the array if there's an image and if $is_intermediate (4th array value) is true or full size. */
        if ( !empty( $image ) && ( true == $image[3] || 'full' == $size ) )
            $links[] = "<a class='image-size-link' href='{$image[0]}' target=_blank>{$image[1]} &times; {$image[2]}</a>";
    }

    /* Join the links in a string and return. */
    return join( ' <span class="sep">/</span> ', $links );
}

On the attachment page, when I click on the image size (rezolutions like 1602 × 1200 / 1920 × 1437 / 1442 × 1080 / 150 × 150 / 2580 × 1932), it will open the image, like for example site.com/wp-content/uploads/2014/10/randomimage-1602×1200.jpg

But instead of opening site.com/wp-content/uploads/2014/10/randomimage-1602×1200.jpg directly, I want it to open a page where that image size will be posted.

Anyone knows how to do this?

thank you

0

Ok, I found the answer (actually paid a programmer to do it) modify to

/* Add the link to the array if there's an image and if $is_intermediate (4th array value) is true or full size. */
if ( !empty( $image ) && ( true == $image[3] || 'full' == $size ) )
$links[] = "<a class='image-size-link' href='/show-image.php?path={$image[0]}' target=_blank>{$image[1]} &times; {$image[2]}</a>";
}

create a file, upload it in your root (or where you want) and add this code in it:

"/>

hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.