<ul class="foogallery-album-gallery-list">
					<?php
					foreach ( $galleries as $gallery ) {
						$img_src  = foogallery_find_featured_attachment_thumbnail_src( $gallery );
						$images   = $gallery->image_count();
						$selected = $album->includes_gallery( $gallery->ID )?'selected' : '';
						$title = $gallery->safe_name();
						?>
						<li class="foogallery-pile">
							<div class="foogallery-gallery-select attachment-preview landscape<?php echo $selected;?>" data-foogallery-id="<?php echo $gallery->ID;?>">
								<div class="thumbnail" style="display: table;">
									<div style="display: table-cell; vertical-align: middle; text-align: center;">
										<img src="<?php echo $img_src;?>"/>
										<h3><?php echo $title;?>
											<span><?php echo $images;?></span>
										</h3>
									</div>
								</div>
								<a class="info foogallery-album-info" href="#"
								   title="<?php _e( 'Edit Album Info', 'foogallery' );?>"
								   data-gallery-title="<?php echo $title;?>"
								   data-gallery-id="<?php echo $gallery->ID;?>"><span class="dashicons dashicons-info"></span></a>
							</div>
						</li>
					<?php }?>
				</ul>
				<div style="clear: both;"></div>
			</div>
		<?php
		}

		public function render_shortcode_metabox( $post ) {
			$album   = $this->get_album( $post );
			$shortcode = $album->shortcode();
			?>
			<p class="foogallery-shortcode">
				<input type="text" id="foogallery-copy-shortcode" size="<?php echo strlen( $shortcode );?>" value="<?php echo htmlspecialchars( $shortcode );?>" readonly="readonly" />
			</p>
			<p>
				<?php _e( 'Paste the above shortcode into a post or page to show the album.', 'foogallery' );?>
			</p>
			<script>
				jQuery(function($) {
					var shortcodeInput = document.querySelector('#foogallery-copy-shortcode');
					shortcodeInput.addEventListener('click', function () {
						try {
							// select the contents
							shortcodeInput.select();
							//copy the selection
							document.execCommand('copy');
							//show the copied message
							$('.foogallery-shortcode-message').remove();
							$(shortcodeInput).after('<p class="foogallery-shortcode-message"><?php _e( 'Shortcode copied to clipboard :)','foogallery' );?></p>');
						} catch(err) {
							console.log('Oops, unable to copy!');
						}
					}, false);
				});
			</script>
		<?php
		}

		public function render_sorting_metabox( $post ) {
			$album = $this->get_album( $post );
			$sorting_options = foogallery_sorting_options();?>
			<p>
				<?php _e('Change the way galleries are sorted within your album. By default, they are sorted in the order you see them.', 'foogallery');?>
			</p>
			<?php
			foreach ( $sorting_options as $sorting_key => $sorting_label ) {?>
				<p>
				<input type="radio" value="<?php echo $sorting_key;?>" <?php checked( $sorting_key === $album->sorting );?> id="FooGallerySettings_AlbumSort_<?php echo $sorting_key;?>" name="<?php echo FOOGALLERY_ALBUM_META_SORT;?>" />
				<label for="FooGallerySettings_AlbumSort_<?php echo $sorting_key;?>"><?php echo $sorting_label;?></label>
				</p><?php
			}
		}

		public function render_settings_metabox( $post ) {
			$album = $this->get_album( $post );
			$available_templates = foogallery_album_templates();
			$album_template = foogallery_default_album_template();
			if (! empty($album->album_template) ) {
				$album_template = $album->album_template;
			}
			if ( false === $album_template ) {
				$album_template = $available_templates[0]['slug'];
			}
			$hide_help = 'on' == foogallery_get_setting( 'hide_gallery_template_help' );
			?>
			<table class="foogallery-album-metabox-settings">
				<tbody>
				<tr class="gallery_template_field gallery_template_field_selector">
					<th>
						<label for="FooGallerySettings_AlbumTemplate"><?php _e( 'Album Template', 'foogallery' );?></label>
					</th>
					<td>
						<select id="FooGallerySettings_AlbumTemplate" name="<?php echo FOOGALLERY_ALBUM_META_TEMPLATE;?>">
							<?php
							foreach ( $available_templates as $template ) {
								$selected = ($album_template === $template['slug'])?'selected' : '';
								echo "<option {$selected} value=\"{$template['slug']}\">{$template['name']}</option>";
							}
							?>
						</select>
						<br />
						<small><?php _e( 'The album template that will be used when the album is output to the frontend.', 'foogallery' );?></small>
					</td>
				</tr>
				<?php
				foreach ( $available_templates as $template ) {
					$field_visibility = ($album_template!== $template['slug'])?'style="display:none"' : '';
					$section          = '';
					$fields = isset( $template['fields'] )? $template['fields'] : array();
					foreach ( $fields as $field ) {
						//allow for the field to be altered by extensions.
						$field = apply_filters( 'foogallery_alter_gallery_template_field', $field, $album );

						$class = "gallery_template_field gallery_template_field-{$template['slug']} gallery_template_field-{$template['slug']}-{$field['id']}";

						if ( isset($field['section']) && $field['section']!== $section ) {
							$section = $field['section'];
							?>
							<tr class="<?php echo $class;?>" <?php echo $field_visibility;?>>
								<td colspan="2"><h4><?php echo $section;?></h4></td>
							</tr>
						<?php }
						if (isset($field['type']) && 'help' == $field['type'] && $hide_help) {
							continue; //skip help if the 'hide help' setting is turned on
						}
						?>
						<tr class="<?php echo $class;?>" <?php echo $field_visibility;?>>
							<?php if ( isset($field['type']) && 'help' == $field['type'] ) {?>
								<td colspan="2">
									<div class="foogallery-help">
										<?php echo $field['desc'];?>
									</div>
								</td>
							<?php } else {?>
								<th>
									<label for="FooGallerySettings_<?php echo $template['slug']. '_'. $field['id'];?>"><?php echo $field['title'];?></label>
								</th>
								<td>
									<?php do_action( 'foogallery_render_gallery_template_field', $field, $album, $template );?>
								</td>
							<?php }?>
						</tr>
					<?php
					}
				}
				?>
				</tbody>
			</table>
		<?php
		