Link to original, non-cropped media file
-
Hey Anders,
I’m coding a page template so images are automatically wrapped in a link to the original image file. Like this:
<?php $image = get_sub_field( 'img' ); if( ! empty( $image ) ) { $url = $image['url']; $alt = $image['alt']; $size = 'large'; $img = $image['sizes'][ $size ]; ?> <a href="<?php echo $url; ?>" title="<?php echo $title; ?>"> <img src="<?php echo $img; ?>" alt="<?php echo $alt; ?>" /> </a> <?php } ?>
However, not surprisingly, this results in a link to the cropped image file, like this:
<a href="https://example.com/wp-content/uploads/img_640x445_acf_cropped.jpg"> <img alt="alt-text" src="https://example.com/wp-content/uploads/img_640x445_acf_cropped.jpg"> </a>
But I need the link to point to the original un-cropped image file, like this:
<a href="https://example.com/wp-content/uploads/img.jpg"> <img alt="alt-text" src="https://example.com/wp-content/uploads/img_640x445_acf_cropped.jpg"> </a>
Any chance you know how to handle this? It’s a pretty important thing for the site I’m working on, so hopefully I can get an answer somewhere. Thanks again for all your fabulous work on this plugin!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Link to original, non-cropped media file’ is closed to new replies.