GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-gravatar-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Gravatar field output for HTML rendering
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.8
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $field_settings = $gravityview->field->as_configuration();
15 
16 // There was no email field setting defined somehow.
17 if ( empty( $field_settings['email_field'] ) ) {
18  return;
19 }
20 
22 
23 $settings['email'] = GravityView_Field_Gravatar::get_email( $field_settings, $gravityview->entry->as_entry() );
24 
25 $settings['args'] = array(
26  'force_display' => true,
27 );
28 
29 /**
30  * @filter `gravityview/fields/gravatar/settings` Modify the Gravatar settings for the field
31  * @param $settings array Settings passed to {@see get_avatar()} for parameters.
32  * @param \GV\Template_Context $gravityview Current context
33  */
34 $settings = apply_filters( 'gravityview/fields/gravatar/settings', $settings, $gravityview );
35 
36 echo get_avatar(
37  \GV\Utils::get( $settings, 'email' ),
38  \GV\Utils::get( $settings, 'size', 96 ),
39  \GV\Utils::get( $settings, 'default', '' ),
40  \GV\Utils::get( $settings, 'alt', '' ),
41  \GV\Utils::get( $settings, 'args', array() ) // You can set via filter above
42 );
static get_email( $field_settings, $entry)
Get the email address to use, based on field settings.
if(empty( $field_settings['email_field'])) $settings
gravityview()
The main GravityView wrapper function.
if(! isset( $gravityview)||empty( $gravityview->template)) $field_settings
Gravatar field output for HTML rendering.