Original image link [complete solution]
-
I don’t know why this is so hard to keep original image link in cropped image. Here’s the simple 3-line solution. Maybe it will be added in 1.1 version:
image_crop-v4.php – line ~ 420
Replace this code:
$value = array( 'id' => $attachment->ID, 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true), 'title' => $attachment->post_title, 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content, 'mime_type' => $attachment->post_mime_type, 'url' => $src[0], 'width' => $src[1], 'height' => $src[2], 'sizes' => array(), );
with this code:
$meta_handler = wp_get_attachment_metadata($attachment->ID); $value = array( 'id' => $attachment->ID, 'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true), 'title' => $attachment->post_title, 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content, 'mime_type' => $attachment->post_mime_type, 'url' => $src[0], 'width' => $src[1], 'height' => $src[2], 'sizes' => array(), 'original_image' => $meta_handler['image_meta']['original_image'] );
and replace this line:
$attachmentData = wp_generate_attachment_metadata( $attachmentId, $targetFilePath );
with this:
$attachmentData = wp_generate_attachment_metadata( $attachmentId, $targetFilePath ); $upload_dir = wp_upload_dir(); $attachmentData['image_meta']['original_image'] = $upload_dir['baseurl'].'/'.$originalImageData['file'];
in returned object there will be link to original image.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Original image link [complete solution]’ is closed to new replies.