Skip to content

Instantly share code, notes, and snippets.

@scyt
Last active January 12, 2022 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scyt/45187170122d4c39875c12e304361fe4 to your computer and use it in GitHub Desktop.
Save scyt/45187170122d4c39875c12e304361fe4 to your computer and use it in GitHub Desktop.
Gravity Perks // Nested Forms // Preview Files Uploaded With GP Media Library
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-current-time-merge-tags.php
*/
/**
* Gravity Perks // Nested Forms // Preview Files Uploaded With GP Media Library
*
* @version 1.0
* @author Scott Buchmann <scott@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
* @copyright 2020 Gravity Wiz
*/
// Update "123" with your form ID.
add_action( 'gpnf_fileupload_display_value_123', function ( $value ) {
$url = attachment_url_to_postid( $value['value'] );
$thumb = wp_get_attachment_image_src( $url );
$value['label'] = '<img src="' . $thumb[0] . '" >';
return $value;
}, 10, 2 );
@scyt
Copy link
Author

scyt commented Jan 12, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment