Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_generate_attachment_metadata

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
164           if ( empty( $missing_sizes ) ) {
165                return $image_meta;
166           }
167
168           // This also updates the image meta.
169           $image_meta = _wp_make_subsizes( $missing_sizes, $image_file, $image_meta, $attachment_id );
170      }
171
172      /** This filter is documented in wp-admin/includes/image.php */
173      $image_meta = apply_filters( 'wp_generate_attachment_metadata', $image_meta, $attachment_id, 'update' );
174
175      // Save the updated metadata.
176      wp_update_attachment_metadata( $attachment_id, $image_meta );
177
178      return $image_meta;
179 }
180
181 /**
182  * Updates the attached file and image meta data when the original image was edited.
 
Line Code
599       *
600       * @since 2.1.0
601       * @since 5.3.0 The `$context` parameter was added.
602       *
603       * @param array  $metadata      An array of attachment meta data.
604       * @param int    $attachment_id Current attachment ID.
605       * @param string $context       Additional context. Can be 'create' when metadata was initially created for new attachment
606       *                              or 'update' when the metadata was updated.
607       */
608      return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id, 'create' );
609 }
610
611 /**
612  * Convert a fraction string to a decimal.
613  *
614  * @since 2.5.0
615  *
616  * @param string $str
617  * @return int|float