Inventory_Presser_Photo_Numberer::save_meta_hash( int $post_id )

Saves an MD5 hash checksum of the attachment file bytes in the attachment post meta. This 32 character string can be used for file comparisons while not taxing the server as much as other methods.

On This Page


Parameters Parameters

$post_id

(int) (Required) The post ID of the attachment.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-photo-numberer.php

	public static function save_meta_hash( $post_id ) {
		// Save a md5 hash checksum of the attachment in meta.
		$file_path = get_attached_file( $post_id );
		if ( false === $file_path ) {
			return;
		}
		update_post_meta(
			$post_id,
			apply_filters( 'invp_prefix_meta_key', 'hash' ),
			hash_file( 'md5', $file_path )
		);
	}