Ticket #3440: 3440.diff
File 3440.diff, 8.2 KB (added by , 18 years ago) |
---|
-
wp-includes/post-template.php
353 353 354 354 $mime = $post->post_mime_type; 355 355 356 $imagedata = get_post_meta($post->ID, '_wp_attachment_metadata', true);356 $imagedata = wp_get_attachment_metadata( $post->ID ); 357 357 358 $file = get_ post_meta($post->ID, '_wp_attached_file', true);358 $file = get_attached_file( $post->ID ); 359 359 360 360 $exts = array('jpg', 'gif', 'png'); 361 362 361 if ( !$fullsize && !empty($imagedata['thumb']) 363 362 && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) 364 363 && file_exists($thumbfile) ) { -
wp-includes/post.php
4 4 // Post functions 5 5 // 6 6 7 function get_attached_file($attachment_id) { 8 return get_post_meta($attachment_id, '_wp_attached_file', true); 7 function get_attached_file( $attachment_id, $unfiltered = false ) { 8 $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); 9 if ( $unfiltered ) 10 return $file; 11 return apply_filters( 'get_attached_file', $file, $attachment_id ); 9 12 } 10 13 14 function update_attached_file( $attachment_id, $file ) { 15 if ( !get_post( $attachment_id ) ) 16 return false; 17 18 $old_file = get_attached_file( $attachment_id, true ); 19 20 $file = apply_filters( 'update_attached_file', $file, $attachment_id ); 21 22 if ( $old_file ) 23 return update_post_meta( $attachment_id, '_wp_attached_file', $file, $old_file ); 24 else 25 return add_post_meta( $attachment_id, '_wp_attached_file', $file ); 26 } 27 11 28 function &get_children($args = '', $output = OBJECT) { 12 29 global $post_cache, $wpdb, $blog_id; 13 30 … … 1331 1348 wp_set_post_categories($post_ID, $post_category); 1332 1349 1333 1350 if ( $file ) 1334 add_post_meta($post_ID, '_wp_attached_file', $file);1351 update_attached_file( $post_ID, $file ); 1335 1352 1336 1353 clean_post_cache($post_ID); 1337 1354 … … 1354 1371 if ( 'attachment' != $post->post_type ) 1355 1372 return false; 1356 1373 1357 $meta = get_post_meta($postid, '_wp_attachment_metadata', true);1358 $file = get_ post_meta($postid, '_wp_attached_file', true);1374 $meta = wp_get_attachment_metadata( $postid ); 1375 $file = get_attached_file( $postid ); 1359 1376 1360 1377 $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = '$postid'"); 1361 1378 … … 1384 1401 return $post; 1385 1402 } 1386 1403 1404 function wp_get_attachment_metadata( $post_id, $unfiltered = false ) { 1405 $post_id = (int) $post_id; 1406 1407 $data = get_post_meta( $post_id, '_wp_attachment_metadata', true ); 1408 if ( $unfiltered ) 1409 return $data; 1410 return apply_filters( 'wp_get_attachment_metadata', $data, $post_id ); 1411 } 1412 1413 function wp_update_attachment_metadata( $post_id, $data ) { 1414 if ( !get_post( $post_id ) ) 1415 return false; 1416 1417 $old_data = wp_get_attachment_metadata( $post_id, true ); 1418 1419 $data = apply_filters( 'wp_update_attachment_metadata', $data, $post_id ); 1420 1421 if ( $old_data ) 1422 return update_post_meta( $post_id, '_wp_attachment_metadata', $data, $old_data ); 1423 else 1424 return add_post_meta( $post_id, '_wp_attachment_metadata', $data ); 1425 } 1426 1387 1427 ?> -
xmlrpc.php
871 871 'guid' => $upload[ 'url' ] 872 872 ); 873 873 // Save the data 874 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id);875 add_post_meta($id, '_wp_attachment_metadata', array());874 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); 875 wp_update_attachment_metadata( $id, array() ); 876 876 877 877 return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) ); 878 878 } -
wp-admin/post.php
78 78 $_POST['post_type'] = 'attachment'; 79 79 80 80 // Update the thumbnail filename 81 $ oldmeta = $newmeta = get_post_meta($post_id, '_wp_attachment_metadata', true);81 $newmeta = wp_get_attachment_metadata( $post_id, true ); 82 82 $newmeta['thumb'] = $_POST['thumb']; 83 83 84 if ( '' !== $oldmeta ) 85 update_post_meta($post_id, '_wp_attachment_metadata', $newmeta, $oldmeta); 86 else 87 add_post_meta($post_id, '_wp_attachment_metadata', $newmeta); 84 wp_update_attachment_metadata( $post_id, $newmeta ); 88 85 89 86 case 'editpost': 90 87 $post_ID = (int) $_POST['post_ID']; -
wp-admin/upgrade-functions.php
466 466 467 467 $meta = get_post_meta($object->ID, 'imagedata', true); 468 468 if ( ! empty($meta['file']) ) 469 add_post_meta($object->ID, '_wp_attached_file', $meta['file']);469 update_attached_file( $object->ID, $meta['file'] ); 470 470 } 471 471 } 472 472 } -
wp-admin/admin-functions.php
2016 2016 return false; 2017 2017 2018 2018 $icon = get_attachment_icon( $post->ID ); 2019 $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true);2019 $attachment_data = wp_get_attachment_metadata( $id ); 2020 2020 $thumb = isset( $attachment_data['thumb'] ); 2021 2021 ?> 2022 2022 <form id="the-attachment-links"> -
wp-admin/upload-functions.php
2 2 function wp_upload_display( $dims = false, $href = '' ) { 3 3 global $post; 4 4 $id = get_the_ID(); 5 $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true);5 $attachment_data = wp_get_attachment_metadata( $id ); 6 6 if ( isset($attachment_data['width']) ) 7 7 list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128); 8 8 ob_start(); … … 57 57 function wp_upload_view() { 58 58 global $style, $post_id, $style; 59 59 $id = get_the_ID(); 60 $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true);60 $attachment_data = wp_get_attachment_metadata( $id ); 61 61 ?> 62 62 <div id="upload-file"> 63 63 <div id="file-title"> … … 98 98 <?php 99 99 if ( $id ) : 100 100 $attachment = get_post_to_edit( $id ); 101 $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true);101 $attachment_data = wp_get_attachment_metadata( $id ); 102 102 ?> 103 103 <div id="file-title"> 104 104 <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style ) … … 229 229 $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; 230 230 $imagedata['file'] = $file; 231 231 232 add_post_meta($id, '_wp_attachment_metadata', $imagedata);232 wp_update_attachment_metadata( $id, $imagedata ); 233 233 234 234 if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { 235 235 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) … … 240 240 if ( @file_exists($thumb) ) { 241 241 $newdata = $imagedata; 242 242 $newdata['thumb'] = basename($thumb); 243 update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);243 wp_update_attachment_metadata( $id, $newdata ); 244 244 } else { 245 245 $error = $thumb; 246 246 } 247 247 } 248 248 } else { 249 add_post_meta($id, '_wp_attachment_metadata', array());249 wp_update_attachment_metadata( $id, array() ); 250 250 } 251 251 252 252 wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id"); -
wp-admin/page.php
71 71 $_POST['post_type'] = 'attachment'; 72 72 73 73 // Update the thumbnail filename 74 $ oldmeta = $newmeta = get_post_meta($page_id, '_wp_attachment_metadata', true);74 $newmeta = wp_get_attachment_metadata( $page_id, true ); 75 75 $newmeta['thumb'] = $_POST['thumb']; 76 76 77 if ( '' !== $oldmeta ) 78 update_post_meta($page_id, '_wp_attachment_metadata', $newmeta, $oldmeta); 79 else 80 add_post_meta($page_id, '_wp_attachment_metadata', $newmeta); 77 wp_update_attachment_metadata( $newmeta ); 81 78 82 79 case 'editpost': 83 80 $page_ID = (int) $_POST['post_ID'];