# charitable/1.8.13/templates/form-fields/picture.php

Charitable – Donation &amp; Fundraising Platform (Donation Forms, Recurring Donations &amp; Fundraising Campaigns), version 1.8.13. 170 lines.

- Page: https://pluginprobe.com/plugins/charitable/1.8.13/code/templates/form-fields/picture.php
- Raw: https://pluginprobe.com/plugins/charitable/1.8.13/raw/templates/form-fields/picture.php
- Modified: 2026-10-01T09:58:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/charitable/1.8.13/code/templates/form-fields/picture.php#L10-L20`.

```php
<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * The template used to display file form fields.
 *
 * @author  WP Charitable LLC
 * @package Charitable/Templates/Form Fields
 * @since   1.0.0
 * @version 1.6.13
 * @version 1.8.8.6
 * @version 1.8.12.4
 */

if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
	return;
}

if ( array_key_exists( 'uploader', $view_args['field'] ) && ! $view_args['field']['uploader'] ) {
	return charitable_template( 'form-fields/file.php', $view_args );
}

$charitable_form          = $view_args['form'];
$charitable_field         = $view_args['field'];
$charitable_classes       = $view_args['classes'];
$charitable_is_required   = isset( $charitable_field['required'] ) ? $charitable_field['required'] : false;
$charitable_placeholder   = isset( $charitable_field['placeholder'] ) ? esc_attr( $charitable_field['placeholder'] ) : '';
$charitable_size          = isset( $charitable_field['size'] ) ? $charitable_field['size'] : 'thumbnail';
$charitable_max_uploads   = isset( $charitable_field['max_uploads'] ) ? $charitable_field['max_uploads'] : 1;
$charitable_max_file_size = isset( $charitable_field['max_file_size'] ) ? $charitable_field['max_file_size'] : wp_max_upload_size();
$charitable_pictures      = isset( $charitable_field['value'] ) ? $charitable_field['value'] : array();

if ( wp_is_mobile() ) {
	$charitable_classes .= ' mobile';
}

if ( ! is_array( $charitable_pictures ) ) {
	$charitable_pictures = array( $charitable_pictures );
}

foreach ( $charitable_pictures as $charitable_i => $charitable_picture ) {
	if ( false === strpos( $charitable_picture, 'img' ) && ! wp_attachment_is_image( $charitable_picture ) ) {
		unset( $charitable_pictures[ $charitable_i ] );
	}
}

/*
 * Ask the same question the AJAX endpoint asks. Without this the field draws a fully
 * working drag-and-drop zone for a logged-out visitor whose uploads charitable_plupload_
 * image_upload() will always refuse - the visitor picks a file and gets an error with no
 * way to succeed. Say so up front instead. Mirrors the disabled state Ambassadors renders
 * for its own gallery field.
 */
$charitable_uploads_enabled = charitable_picture_uploads_enabled(
	$charitable_field['key'],
	isset( $charitable_field['parent_id'] ) ? absint( $charitable_field['parent_id'] ) : 0
);

$charitable_has_max_uploads = count( $charitable_pictures ) >= $charitable_max_uploads;
$charitable_params          = array(
	'runtimes'            => 'html5,silverlight,flash,html4',
	'file_data_name'      => 'async-upload',
	'container'           => $charitable_field['key'] . '-dragdrop',
	'browse_button'       => $charitable_field['key'] . '-browse-button',
	'drop_element'        => $charitable_field['key'] . '-dragdrop-dropzone',
	'multiple_queues'     => true,
	'url'                 => admin_url( 'admin-ajax.php' ),
	'flash_swf_url'       => includes_url( 'js/plupload/plupload.flash.swf' ),
	'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
	'multipart'           => true,
	'urlstream_upload'    => true,
	'filters'             => array(
		array(
			'title'      => _x( 'Allowed Image Files', 'image upload', 'charitable' ),
			'extensions' => 'jpg,jpeg,gif,png,webp',
		),
	),
	'multipart_params'    => array(
		'field_id'    => $charitable_field['key'],
		'action'      => 'charitable_plupload_image_upload',
		'_ajax_nonce' => wp_create_nonce( "charitable-upload-images-{$charitable_field[ 'key' ]}" ),
		'post_id'     => isset( $charitable_field['parent_id'] ) && strlen( $charitable_field['parent_id'] ) ? $charitable_field['parent_id'] : '0',
		'size'        => $charitable_size,
		'max_uploads' => $charitable_max_uploads,
	),
);

if ( $charitable_uploads_enabled ) {
	wp_enqueue_script( 'charitable-plup-fields' );
}

wp_enqueue_style( 'charitable-plup-styles' );

?>
<div id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>" class="<?php echo esc_attr( $charitable_classes ); ?>">
	<?php if ( isset( $charitable_field['label'] ) ) : ?>
		<label>
			<?php echo wp_kses_post( $charitable_field['label'] ); ?>
			<?php if ( $charitable_is_required ) : ?>
				<abbr class="required" title="<?php esc_html_e( 'Required', 'charitable' ); ?>">*</abbr>
			<?php endif ?>
		</label>
	<?php endif ?>
	<?php if ( isset( $charitable_field['help'] ) ) : ?>
		<p class="charitable-field-help"><?php echo $charitable_field['help']; // phpcs:ignore  ?></p>
	<?php endif ?>
	<?php if ( ! $charitable_uploads_enabled ) : ?>
		<?php
		/*
		 * No .charitable-drag-drop class here on purpose: that class is what
		 * charitable-plupload-fields.js constructs an Uploader from. Not printing the params
		 * also keeps the user-0 nonce off public pages, so there is no token to scrape.
		 */
		?>
		<div class="charitable-drag-drop-disabled">
			<p class="charitable-drag-drop-info"><?php esc_html_e( 'Image uploads are available to logged-in users. Please log in or create an account to add an image.', 'charitable' ); ?></p>
			<?php if ( ! empty( $charitable_pictures ) ) : ?>
				<ul class="charitable-drag-drop-images charitable-drag-drop-images-<?php echo esc_attr( $charitable_max_uploads ); ?>">
					<?php
					foreach ( $charitable_pictures as $charitable_image ) :
						charitable_template(
							'form-fields/picture-preview.php',
							array(
								'image' => $charitable_image,
								'field' => $charitable_field,
							)
						);
					endforeach;
					?>
				</ul>
			<?php endif ?>
		</div>
	<?php else : ?>
		<div id="<?php echo esc_attr( $charitable_field['key'] ); ?>-dragdrop"
			class="charitable-drag-drop"
			data-max-size="<?php echo esc_attr( $charitable_max_file_size ); ?>"
			data-images="<?php echo esc_attr( $charitable_field['key'] ); ?>-dragdrop-images"
			data-params="<?php echo esc_attr( wp_json_encode( $charitable_params ) ); ?>">
			<div id="<?php echo esc_attr( $charitable_field['key'] ); ?>-dragdrop-dropzone" class="charitable-drag-drop-dropzone" <?php echo $charitable_has_max_uploads ? 'style="display:none;"' : ''; ?>>
				<p class="charitable-drag-drop-info"><?php echo esc_html( 1 === $charitable_max_uploads ? _x( 'Drop image here', 'image upload', 'charitable' ) : _x( 'Drop images here', 'image upload plural', 'charitable' ) ); ?></p>
				<p><?php echo esc_html_x( 'or', 'image upload', 'charitable' ); ?></p>
				<p class="charitable-drag-drop-buttons">
					<button id="<?php echo esc_attr( $charitable_field['key'] ); ?>-browse-button" class="button" type="button"><?php echo esc_html_x( 'Select Files', 'image upload', 'charitable' ); ?></button>
				</p>
			</div>
			<div class="charitable-drag-drop-image-loader" style="display: none;">
				<p class="loader-title"><?php esc_html_e( 'Uploading...', 'charitable' ); ?></p>
				<ul class="images"></ul>
			</div>
			<ul id="<?php echo esc_attr( $charitable_field['key'] ); ?>-dragdrop-images" class="charitable-drag-drop-images charitable-drag-drop-images-<?php echo esc_attr( $charitable_max_uploads ); ?>">
				<?php
				foreach ( $charitable_pictures as $charitable_image ) :
					charitable_template(
						'form-fields/picture-preview.php',
						array(
							'image' => $charitable_image,
							'field' => $charitable_field,
						)
					);
				endforeach;
				?>
			</ul>
		</div>
	<?php endif ?>
</div>

```
