Set Uploaded Image Data

Code

Filename: gpml-set-uploaded-images-data.php

<?php
/**
 * Gravity Perks // Media Library // Set Uploaded Image Data
 * https://gravitywiz.com/documentation/gravity-forms-media-library/
 */
add_filter( 'gpml_media_data', function( $media, $field, $entry ) {

	$media['post_data']['post_title']                            = 'Boom!';
	$media['post_data']['post_content']                          = 'This is the description.';
	$media['post_data']['post_excerpt']                          = 'This is the caption.';
	$media['post_data']['post_meta']['_wp_attachment_image_alt'] = 'This is the alt text.';

	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.