Creating an image gallery from wordpress uploads directory

Description

This code allows you to create an image gallery from a ftp folder. In this case we used the wordpress uploads folder and created a subdirectory call missiontrips. Inside the mission trips folder will be many subfolders with the id of the post that the galley will show. you must also create a custom field […]

This code allows you to create an image gallery from a ftp folder. In this case we used the wordpress uploads folder and created a subdirectory call missiontrips. Inside the mission trips folder will be many subfolders with the id of the post that the galley will show. you must also create a custom field called galleryid and assign it the id of the post. Any image you place inside that sub folder should appear on the page used in no particular order

PHP Source Code

                        
                          <!--Photo uploads start-->
		<div id="instafeed">
		<?php
		$uploads = wp_upload_dir();
		echo '<ul>';
		if ($dir = opendir($uploads['basedir'].'/'.'missiontrips'.'/'. $post->ID)) {
			while (false !== ($file = readdir($dir))) {
				if ($file != "." && $file != "..") {
					?>
					
			 <a class="fancybox" href="/wp-content/uploads/missiontrips/<?php $values = get_post_custom_values("galleryid"); echo ($values[0] ? $values[0] : "" ); ?>/<?php echo $file; ?>">
					<img src="/wp-content/uploads/missiontrips/<?php $values = get_post_custom_values("galleryid"); echo ($values[0] ? $values[0] : "" ); ?>/<?php echo $file; ?>" title="<?php echo $file; ?>">
				</a> 
			
			<?php }
			}
			closedir($dir);
		}
		echo '</ul>';
		?>
		</div>
		<!--Photo uploads end-->                        
                        


Post Categories