Jump to content

Change IFrame with Generated Thumbnail


Nightasy
Go to solution Solved by Nightasy,

Recommended Posts

Heya all,

 

So I've completed my first semester on PHP programming. I got an A, ./flex ! Anyhow, I'm trying to take what I've learned and practice with it. I ran into a bit of a road block and after spending a day trying to figure it out I decided it was time to come ask the pros 8D.

 

I have some thumbnails inside a folder that are dynamically generated when a user visits a page. What I am trying to do with the thumbnails is have them, when clicked, change the photo inside of an iframe. Unfortunately this is not working.

 

Well, enough gabbing. Here's the code that is the culprit of my problem. I think.

<?php
require ('includes/photo_functions.php');
$images_dir = "uploads/" . $_SESSION['username'] . "/photos/";
$thumbs_dir = "uploads/" . $_SESSION['username'] . "/photos/thumbs/";
$thumbs_width = 200;
$images_per_row = 3;

/** generate photo gallery **/
$image_files = get_files($images_dir);
if(count($image_files)) {
	$index = 0;
	foreach($image_files as $index=>$file) {
		$index++;
		$thumbnail_image = $thumbs_dir.$file;
		if(!file_exists($thumbnail_image)) {
			$extension = get_file_extension($thumbnail_image);
			if($extension) {
				make_thumb($images_dir.$file,$thumbnail_image,$thumbs_width,$extension);
			}
		}
		
		echo '<a href="#null" onClick="inner_Iframe.location="',$images_dir.$file,'" class="photo-link"><img class="photo-link" src="',$thumbnail_image,'" /></a>';	
		if($index % $images_per_row == 0) { echo '<div class="clear"></div>'; }
	}
	echo '<div class="clear"></div>';
}
else {
	echo '<p>There are no images in this gallery.</p>';
}
?>

Any help would be appreciated. I'm hoping this is a logical error or perhaps poorly placed quotations?

 

Best Regards,

Nightasy

Edited by Nightasy
Link to comment
Share on other sites

I did some more testing and changed line 22 to this.

echo '<a href="',$images_dir.$file,'" target="inner_Iframe"><img class="photo-link" src="',$thumbnail_image,'" /></a>';

Now it works on Google Chrome but on Internet Explorer and Firefox it always opens the image in a new window instead of displaying the image inside the iframe. Anyone know why those browsers are doing this but Chrome is not.

 

Oh and btw, Chrome is giving me this error.

Resource interpreted as Document but transferred with MIME type image/jpeg: "http://localhost/picpoof/uploads/Poofer/photos/4_Photo9.jpg".

 

It code works in Chrome but that error is coming up.

Edited by Nightasy
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.