Set Uploaded Image Data by Field Value


Filename: gpml-set-uploaded-images-data-by-field-value.php

 * Gravity Perks // Media Library // Set Uploaded Image Data by Field Value
add_filter( 'gpml_media_data', function( $media, $field, $entry ) {

	// Replace "1", "2", "3" and "4" in each line below with the ID of the field that will contain value that should be used for each image property.
	$media['post_data']['post_title']                            = rgpost( 'input_1' );
	$media['post_data']['post_content']                          = rgpost( 'input_2' );
	$media['post_data']['post_excerpt']                          = rgpost( 'input_3' );
	$media['post_data']['post_meta']['_wp_attachment_image_alt'] = rgpost( 'input_4' );

	return $media;
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.