Changeset 4612
- Timestamp:
- 12/05/2006 10:37:19 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r4610 r4612 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 ?> -
trunk/wp-admin/page.php
r4424 r4612 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': -
trunk/wp-admin/post.php
r4495 r4612 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': -
trunk/wp-admin/upgrade-functions.php
r4556 r4612 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 } -
trunk/wp-admin/upload-functions.php
r4466 r4612 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); … … 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"> … … 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"> … … 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 ) { … … 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; … … 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 -
trunk/wp-includes/post-template.php
r4603 r4612 354 354 $mime = $post->post_mime_type; 355 355 356 $imagedata = get_post_meta($post->ID, '_wp_attachment_metadata', true);357 358 $file = get_ post_meta($post->ID, '_wp_attached_file', true);356 $imagedata = wp_get_attachment_metadata( $post->ID ); 357 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)) -
trunk/wp-includes/post.php
r4606 r4612 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 ); 12 } 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 ); 9 26 } 10 27 … … 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); … … 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'"); … … 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 ?> -
trunk/xmlrpc.php
r4569 r4612 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 ) );
Note: See TracChangeset
for help on using the changeset viewer.