19 var
$icon =
'dashicons-format-image';
22 $this->label = esc_html__(
'Post Image',
'gk-gravityview' );
23 parent::__construct();
28 unset ( $field_options[
'search_filter'] );
30 if(
'edit' === $context ) {
31 return $field_options;
39 return $field_options;
57 if ( ! is_string(
$value ) ) {
64 if( preg_match(
'/\|\:\|/',
$value ) ) {
95 $input_name =
"input_{$id}";
100 $img_array = self::explode_value(
$value );
102 if( ! empty( $img_array[
'url'] ) ) {
104 $img_name = basename( $img_array[
'url'] );
111 if( empty( GFFormsModel::$uploaded_files[
$form_id ][ $input_name ] ) ) {
112 GFFormsModel::$uploaded_files[
$form_id ][ $input_name ] = $img_name;
117 add_filter(
'gform_is_entry_detail',
'__return_false' );
118 add_filter(
'gform_is_form_editor',
'__return_false' );
120 $input_value = array(
121 "{$id}.1" => \
GV\Utils::get( $img_array,
'title' ),
122 "{$id}.4" => \
GV\Utils::get( $img_array,
'caption' ),
123 "{$id}.7" => \
GV\Utils::get( $img_array,
'description' ),
127 $gf_post_image_field_output =
$field->get_field_input(
$form, $input_value );
130 remove_filter(
'gform_is_entry_detail',
'__return_false' );
131 remove_filter(
'gform_is_form_editor',
'__return_false' );
139 if ( null !== $img_name ) {
140 $current_file = sprintf(
"<input name='%s' id='%s' type='hidden' value='%s' />", $input_name,
$field_id, esc_url_raw( $img_array[
'url'] ) );
141 $gf_post_image_field_output = str_replace(
'<span class=\'ginput_preview\'>',
'<span class=\'ginput_preview\'>'.$current_file, $gf_post_image_field_output );
144 return $gf_post_image_field_output;
Modify field settings by extending this class.
field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id)
static explode_value( $value)
Convert Gravity Forms |:|-separated image data into an array.
add_field_support( $key, &$field_options)
if(gravityview() ->plugin->is_GF_25()) $form
Add custom options for Post Image fields.
new GravityView_Field_Post_Image
if(empty( $created_by)) $form_id
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed