This is actually a php article and not a block, but I figured it would work here. I wrote it because I needed to have an image gallery now and I didn't like anything else that I could find that's out there. I don't want people to add comments or ratings or to keep track of how many times it is viewed. I just want a simple image gallery where people can look at the photos I've collected.
I started with the gallery from mk_portal, but did a whole lot of altering of the code. About all that's left of the mk_portal code is the naming conventions of the files, the creation of the thumbnails, and the idea of "father" categories. When you upload an image (only one file at a time), it creates a thumbnail, renames the file and adds the information to the database. You can also edit the accompanying text for each image, delete the image, and create, move, delete, rename and reorder the categories. On the main category page, it displays a random image from that category and all the subcategories. As you go through the full-sized images, it displays the previous and next thumbnails, as well as "breadcrumbs" for where you've been and where you can go, category-wise. If the image is too large to fit nicely on a page, it resizes the image (just by the html tag), and makes the image clickable so you can open a separate window and get the real size photo.
I had my site password protected, but undid it so people could see the image gallery (http://site.jpdeni.com/index.php?page=7). This site is far, far from done. :) You won't be able to see the admin functions, but you can see what a user would see.
I didn't really intend this to be for anyone but me, so I didn't include code to create the database tables. You'll need to do that yourself within phpMyAdmin or something. You'll need two tables:
Table name: gallery
Fields:
gallery_id -- type: int(11) -- auto_increment
gallery_cat_id -- type: int(11)
title -- type: varchar(255)
description -- type: text
file -- type: text
date -- int(10)
Table name: gallery_cats
Fields:
gallery_cat_id -- type: int(11) -- auto_increment
gallery_cat -- type: varchar(255)
sort_order -- int(4)
father -- int(10)
Create a php page and paste the following into it. You'll need to change all the instances of page=7 to match whatever the page number is that you're using. Probably the easiest way to do this is to first paste the code into a text editor and do a search-and-replace.
global $scripturl, $cat_name, $cat_parent, $child_cats, $cat_order, $nbsp;
$category_list = '';
// This is for the thumbnail pages
$number_of_cols = 4;
$number_of_rows = 4;
$max_on_page = $number_of_cols * $number_of_rows;
$directory = '/path/to/your/image/directory';
$nbsp = '&nb' . 'sp;' . '&nb' . 'sp;';
$perm= $GLOBALS['user_info']['groups'][0];
if ($perm == 1 || $perm ==2)
$can_edit=1;
else
$can_edit = 0;
isset($_GET['cat']) ? $cat = $_GET['cat'] : $cat=0;
isset($_GET['p']) ? $p = $_GET['p'] : $p=1;
isset($_GET['pic']) ? $pic = $_GET['pic'] : $pic=0;
if (isset($_POST['op']))
$operation = $_POST['op'];
elseif (isset($_GET['op']))
$operation = $_GET['op'];
else
$operation = '';
$query = db_query(
"SELECT *
FROM gallery_cats
ORDER BY sort_order", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
$id = $row['gallery_cat_id'];
$cat_name[$id] = $row['gallery_cat'];
$cat_parent[$id] = $row['father'];
$cat_order[$id] = $row['sort_order'];
}
if ($can_edit==1)
{
if ($operation=='Upload file')
{
$file = $_FILES['FILE_UPLOAD']['tmp_name'];
$file_name = $_FILES['FILE_UPLOAD']['name'];
$gallery_cat_id = $_POST['gallery_cat_id'];
$title = $_POST['title'];
$description = $_POST['description'];
$file_ext = 'jpg';
$ext = strtolower($file_ext);
$query = db_query(
"SELECT gallery_id
FROM gallery
ORDER BY gallery_id DESC LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
$totr = $row['gallery_id'];
++$totr;
$image = "a_"."$totr".".$ext";
move_uploaded_file("$file", "$directory" . '/' . "$image");
$cdata = time();
$thumb = "t_$image";
$source = "$directory" . '/' . "$image";
$dest = "$directory" . '/' . "$thumb";
CreateImage(120,$source,$dest);
db_query(
"INSERT INTO gallery(gallery_cat_id, title, description, file, date)
VALUES('$gallery_cat_id', '$title', '$description', '$image', '$cdata')", __FILE__, __LINE__);
echo 'file uploaded';
}
elseif ($operation=='Add Category')
{
$gallery_cat = $_POST['gallery_cat'];
$father = $_POST['father'];
db_query(
"INSERT INTO gallery_cats(gallery_cat_id, gallery_cat, sort_order, father)
VALUES('', '$gallery_cat', '0', '$father')", __FILE__, __LINE__);
echo 'category added';
}
elseif ($operation=='Change Category Name')
{
$gallery_cat = $_POST['gallery_cat'];
$gallery_cat_id = $_POST['gallery_cat_id'];
db_query("UPDATE gallery_cats
SET gallery_cat='$gallery_cat'
WHERE gallery_cat_id='$gallery_cat_id' LIMIT 1", __FILE__, __LINE__);
echo 'category name changed';
}
elseif ($operation=='Delete Category')
{
$gallery_cat_id = $_POST['gallery_cat_id'];
$error = '';
$query = db_query(
"SELECT gallery_id
FROM gallery
WHERE gallery_cat_id = $gallery_cat_id", __FILE__, __LINE__);
if (mysql_num_rows($query))
$error = 'You must first move all of the images from the category.<br />';
$query = db_query(
"SELECT gallery_cat_id
FROM gallery_cats
WHERE father = $gallery_cat_id", __FILE__, __LINE__);
if (mysql_num_rows($query))
$error = 'You must first delete any child categories of this category.<br />';
if ($error > '')
echo $error . 'Category not deleted';
else {
db_query("DELETE FROM gallery_cats
WHERE gallery_cat_id='$gallery_cat_id' LIMIT 1", __FILE__, __LINE__);
echo 'category deleted';
}
}
elseif ($operation=='Re-order Categories')
{
$query2 = db_query("
SELECT gallery_cat_id
FROM gallery_cats", __FILE__, __LINE__);
$row2 = '';
while ( $row2 = mysql_fetch_assoc($query2))
{
$test = 'sort_order_cat' . $row2['gallery_cat_id'];
$sort_order=$_POST[$test];
$gallery_cat_id = $row2['gallery_cat_id'];
db_query("UPDATE gallery_cats
SET sort_order='$sort_order'
WHERE gallery_cat_id='$gallery_cat_id' LIMIT 1", __FILE__, __LINE__);
}
echo 'categories re-ordered';
}
}
if ($can_edit==1 && $operation=='admin')
{
$ta_end = '<' . '/textarea' . '>';
echo '<table border="1"><tr valign="top">';
// Upload file form
echo '<td><form action="index.php?page=7" name="UPLOAD" method="post" enctype="multipart/form-data">
<table border="0">
<tr><td colspan=2> <p style="text-align:center"> Upload a new file.</p>Please be sure to fill out all of the fields and only upload .jpg files.</td></tr>';
echo '<tr><td>Category:</td><td><select name="gallery_cat_id">';
display_child_cats('0', '0', 'select', '0');
echo '
</select></td></tr>
<td width="10%">Title</td>
<td width="90%"><input type="text" name="title" size="52" /></td>
</tr>
<tr>
<td width="10%" valign="top">Description</td>
<td width="90%"><textarea cols="50" rows="10" name="description" />' . $ta_end . '</td>
</tr>
<tr>
<td width="10%">File</td>
<td width="90%"><input type="file" name="FILE_UPLOAD" size="50" /></td>
</tr>
<tr>
<td colspan="2" style="text-align:center"> <input type="submit" name="op" value="Upload file" /></td>
</tr>
</table>
</form></td></tr>';
// Add category
echo '<tr><td>
<table border="0">
<tr><td> <form action="index.php?page=7" method="post">';
echo '<tr><td align="right">Parent category:</td><td><select name="father">';
echo '<option value="0">Main category -- no parent</option>';
display_child_cats('0', '0', 'select', '0');
echo '
</select></td></tr>';
echo '
<tr><td align="right">Category name:</td>
<td><input type="text" name="gallery_cat" size="52" /></td></tr>';
echo '<tr><td colspan="2" style="text-align:center"><input type="submit" name="op" value="Add Category" /></form>';
echo '</td></tr><hr />';
// Change category name
echo '<form action="index.php?page=7" method="post">';
echo '<tr><td align="right">Change this category:</td><td><select name="gallery_cat_id">';
display_child_cats('0', '0', 'select', '0');
echo '
</select></td></tr>';
echo '
<tr><td align="right">To this:</td>
<td><input type="text" name="gallery_cat" size="52" /></td></tr>';
echo '<tr> <td colspan="2" style="text-align:center"> <input type="submit" name="op" value="Change Category Name" /></form>';
echo '</td></tr><hr />';
// Delete category
echo '<tr><td colspan=2>Note that you can only delete a category if there are no images in that category and if the category has no child categories.</td></tr>';
echo '<form action="index.php?page=7" method="post">';
echo '<tr><td align="right">Delete this category:</td><td><select name="gallery_cat_id">';
display_child_cats('0', '0', 'select', '0');
echo '
</select></td></tr>';
echo '<tr><td colspan="2" style="text-align:center"><input type="submit" name="op" value="Delete Category" /></form>';
echo '</td></tr>';
echo '</table>';
echo '</td></tr>';
// Order categories
echo '<tr><td>Order categories<br />';
echo '<form action="index.php?page=7" method="post">';
display_child_cats('0', '0', 'form', '0');
echo '<p style="text-align:center"><input type="submit" name="op" value="Re-order Categories" /></p></form>';
echo '</td></tr>';
echo '</table>';
}
else
{
if (isset($_POST['edit_pic']) && $can_edit )
{
$cat = $_POST['oldcat'];
$gallery_id = $_POST['gallery_id'];
$gallery_cat_id = $_POST['gallery_cat_id'];
$description = $_POST['description'];
$title = $_POST['title'];
if ($cat == $gallery_cat_id)
$pic = $_POST['gallery_id'];
else
$pic = 0;
db_query("UPDATE gallery
SET gallery_cat_id='$gallery_cat_id', title='$title', description='$description'
WHERE gallery_id='$gallery_id' LIMIT 1", __FILE__, __LINE__);
echo 'edited';
}
if (isset($_POST['del_pic']) && $can_edit)
{
$gallery_id = $_POST['gallery_id'];
$file = $_POST['file'];
$thumb = "t_$file";
db_query("DELETE FROM gallery
WHERE gallery_id='$gallery_id' LIMIT 1", __FILE__, __LINE__);
unlink($directory . '/' . $file);
unlink($directory . '/' . $thumb);
echo 'deleted';
}
// One picture
if ($pic > 0) {
$query = db_query(
"SELECT *
FROM gallery
WHERE gallery_id = $pic
LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
$gallery_cat_id = $row['gallery_cat_id'];
$query2 = db_query(
"SELECT gallery_id, file
FROM gallery
WHERE gallery_cat_id = $gallery_cat_id
ORDER BY gallery_id DESC", __FILE__, __LINE__);
while ($row2 = mysql_fetch_assoc($query2))
{
$pics_in_cat[] = $row2['gallery_id'];
$pic_file[] = $row2['file'];
}
$current = array_search($row['gallery_id'],$pics_in_cat);
$numpix = mysql_num_rows($query2) - 1;
if ($current > 0)
{
$prev = $pics_in_cat[$current-1];
$prevthumb = 't_' . $pic_file[$current-1];
}
else
$prev = -1;
if ($current < $numpix)
{
$next = $pics_in_cat[$current+1];
$nextthumb = 't_' . $pic_file[$current+1];
}
else
$next = -1;
$cat= $row['gallery_cat_id'];
echo '<center><table width="800">';
echo '<tr valign=top> <td width="15"> </td> <td align=left width="120">';
if ($prev >-1)
echo '<a href="' . $scripturl . '?page=7&pic=' . $prev . '"> <img src="/album/' . $prevthumb . '" border="0" alt="Previous" /> </a>';
echo '<table><tr><td>' . breadcrumbs($gallery_cat_id,$pic) . '<br /><br /></td>';
echo '</tr></table>';
echo '</td><td width="15"> </td>';
echo '<td width="500"><center><table border="3"><tr><td>';
$picture = '/album/' . $row['file'];
$picturedir = $directory . '/' . $row['file'];
list($width, $height, $type, $attr) = getimagesize($picturedir);
if ($width > 500) {
$small_width = 500;
$small_height = ceil(500 * $height / $width);
$smattr = 'width=' . $small_width . ' height=' . $small_height;
$windowattr = 'width=' . $width . ',height=' . $height;
echo '<a href="' . $picture. '" onclick="window.open(' . "'" . $picture . "','popup','" . $windowattr . ',scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0' . "'" . '); return false"><img src="' . $picture . '" ' . $smattr . ' border="0" alt="Click for bigger picture" /></a>';
}
else
echo ' <img src="' . $picture . '" ' . $attr . ' border="0" alt="" /> ';
echo '</td></tr></table></center></td>';
echo '<td width="15"> </td> <td align=right width="120">';
if ($next > -1)
echo '<a href="' . $scripturl . '?page=7&pic=' . $next . '"><img src="/album/' . $nextthumb . '" border="0" alt="Next" /></a>';
echo '</td><td width="15"> </td></tr>';
echo '<tr> <td></td><td></td><td></td> <td><center>' . $row['title'] . '</center></td><td></td><td></td><td></td></tr>';
echo '<tr><td></td><td></td><td></td><td><center>' . $row['description'] . '</center></td><td></td><td></td><td></td></tr>';
echo '</table>';
if ($can_edit)
{
echo '<hr /><table><tr valign=top><td width="50%">';
echo '<form action="index.php?page=7" method=post><table>';
echo '<input type="hidden" name="oldcat" value="' . $cat . '">';
echo '<input type="hidden" name="gallery_id" value="' . $row['gallery_id'] . '">';
echo '<tr><td>Category:</td><td><select name="gallery_cat_id">';
display_child_cats('0', '0', 'select', $cat);
echo '</select></td></tr>';
echo '<tr><td>Title:</td><td><input type="text" name="title" size=30 value="'. $row['title'] .'">';
echo '<tr><td>Description:</td><td><textarea name="description" rows=10 cols=30>';
echo $row['description'] . '</' . 'textarea' . '/></td></tr>';
echo '<tr><td colspan=2><input type="submit" name=edit_pic value="Edit this picture"></td></tr>';
echo '</table></form></td>';
echo '<form action="index.php?page=7" method=post>';
echo '<input type="hidden" name="gallery_id" value="' . $row['gallery_id'] . '">';
echo '<input type="hidden" name="file" value="' . $row['file'] . '">';
echo '<td>This will delete the main picture, the thumbnail and the record from the database.
There will be no "Are you sure?" button.
You might want to save the main file to your hard drive in case you change your mind and want to add it back again.';
echo '<p style="text-align:center"><input type="submit" name=del_pic value="Delete this picture"></p></td>';
echo '</tr></table>';
}
echo page_numbers($cat,$max_on_page,$p,$pic);
if ($can_edit)
echo '<br /><a href="' . $scripturl . '?page=7&op=admin">Image Admin</a>';
}
// Category index page
elseif ($cat > 0) {
$start = ($p-1) * $max_on_page;
$query = db_query(
"SELECT gallery_id, file
FROM gallery
WHERE gallery_cat_id = $cat
ORDER BY gallery_id DESC
LIMIT $start, $max_on_page", __FILE__, __LINE__);
echo '<table width=100%><tr>';
$k=0;
while ($row = mysql_fetch_assoc($query))
{
$file = $row['file'];
$thumb = "t_$file";
$pic_number = $row['gallery_id'];
echo '<td height="180"><center> <a href="' . $scripturl . '?page=7&pic=' . $pic_number . '">
<img src="/album/' . $thumb . '" border="0" alt="" /></a> </center></td>';
if (($k%$number_of_cols == ($number_of_cols-1)) && ($k < $max_on_page))
echo '</tr><tr>';
++$k;
}
echo '</tr></table>';
echo '<table><tr><td>' . breadcrumbs($cat,$pic) . '</td></tr></table>';
echo page_numbers($cat,$max_on_page,$p,$pic);
if ($can_edit)
echo '<br /> <a href="' . $scripturl . '?page=7&op=admin">Image Admin</a>';
}
else {
// Image index page
$category = array();
echo '<table width="100%"><tr>';
$query = db_query(
"SELECT gallery_cat_id, gallery_cat
FROM gallery_cats
WHERE father = 0
ORDER BY sort_order", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
$child_cats = array();
$category[] = '<a href="' . $scripturl . '?page=7&cat=' . $row['gallery_cat_id'] . '">' . $row['gallery_cat'] . '</a>';
$child_cats = display_child_cats($row['gallery_cat_id'], '0', 'random','0');
$child_cats[] = $row['gallery_cat_id'];
$randomimagequery = "SELECT file, gallery_id FROM gallery WHERE gallery_cat_id=";
$randomimagequery .= implode(" || gallery_cat_id=",$child_cats);
$randomimagequery .= " ORDER BY rand() LIMIT 1";
$randomrecord = mysql_fetch_row(mysql_query($randomimagequery));
$rfile = $randomrecord[0];
$pic = $randomrecord[1];
$thumb = "t_$rfile";
$rand_image_thumb[] = '<a href="' . $scripturl . '?page=7&pic=' . $pic . '">
<img src="/album/' . $thumb . '" border="0" alt="" /></a>';
}
$last_cat = count($category);
$k = 0;
while ($k < count($category))
{
echo '<td width=25% align=center height="180">' . $rand_image_thumb[$k] . '</td>';
echo '<td width=25%>' . $category[$k] . '</td>';
if ($k%2)
echo '</tr><tr>';
++$k;
}
if ($k%2)
echo '<td>' . $nbsp . '</td><td> </td>';
echo '</tr></table>';
if ($can_edit)
echo '<br /><a href="' . $scripturl . '?page=7&op=admin">Image Admin</a>';
}
}
//****************
// FUNCTIONS
//****************
function breadcrumbs($cat,$pic)
{
global $scripturl, $nbsp,$cat_name;
echo '<a href="' . $scripturl . '?page=7">Image index</a><br />';
$level = 1;
$path = parents_path($cat);
foreach ($path as $value)
{
echo str_repeat($nbsp,$level) . '<a href="' . $scripturl . '?page=7&cat=' . $value . '">' . $cat_name[$value]. '</a><br />';
++$level;
}
if ($pic > 0)
echo str_repeat($nbsp,$level) . '<a href="' . $scripturl . '?page=7&cat=' . $cat . '">' . $cat_name[$cat]. '</a><br />';
else
echo str_repeat($nbsp,$level) . $cat_name[$cat]. '<br />';
++$level;
display_child_cats($cat, $level, 'echo','0');
}
function CreateImage($size,$source,$dest,$border=0) {
$imgsize = GetImageSize($source);
$width = $imgsize[0];
$height = $imgsize[1];
$new_width = $size;
$new_height = ceil($size * $height / $width);
$im = @ImageCreateFromJPEG($source);
$new_im=@ImageCreateTrueColor($new_width,$new_height);
if ($new_im) {
ImageCopyResized($new_im,$im,0,0,0,0,$new_width,$new_height,ImageSX($im),ImageSY($im));
ImageJPEG($new_im,$dest,90);
ImageDestroy($new_im);
}
}
function display_child_cats($parent, $level, $output, $cat) {
global $cat_name, $cat_parent, $scripturl, $child_cats, $cat_order ;
$nbsp = '&nb' . 'sp;' . '&nb' . 'sp;';
// retrieve all children of $parent
$children = array_keys($cat_parent,$parent);
// display each child
foreach ($children as $value)
{
// indent and display the title of this child
if ($output == 'form')
echo str_repeat($nbsp,$level+1) . '<input type="text" name="sort_order_cat' . $value . '" value="' . $cat_order[$value] . '" size="3" /> ' . $cat_name[$value] . '<br />';
elseif ($output == 'echo')
echo str_repeat($nbsp,$level+1) . '<a href="' . $scripturl . '?page=7&cat=' . $value . '">' . $cat_name[$value]. '</a><br />';
elseif ($output == 'select')
{
echo '<option value="' . $value . '"';
if ($value == $cat) { echo ' SELECTED '; }
echo '>' . str_repeat('--',$level+1). $cat_name[$value] . '</option>';
}
$child_cats[] = $value;
// call this function again to display this child's children
display_child_cats($value, $level+1, $output, $cat);
}
if ($output == 'random')
return $child_cats;
}
function parents_path($cat)
{
global $cat_name, $cat_parent, $scripturl;
$path = array();
if ($cat_parent[$cat] > 0)
{
$path[] = $cat_parent[$cat];
$path = array_merge(parents_path($cat_parent[$cat]), $path);
}
return $path;
}
function page_numbers($cat,$max_on_page,$p)
{
global $scripturl;
// Print out page numbers
$pix_in_cat_query = db_query(
"SELECT *
FROM gallery
WHERE gallery_cat_id = $cat", __FILE__, __LINE__);
$pix_in_cat = mysql_num_rows($pix_in_cat_query);
$number_of_pages = intval($pix_in_cat/$max_on_page) + ($pix_in_cat%$max_on_page > 1);
$return = '<div align=center>';
for ($i=1; $i<=$number_of_pages;++$i)
{
if ($i == $p)
$return .= '- ' . $i . ' -';
else
$return .= '- <a href="' . $scripturl . '?page=7&cat=' . $cat . '&p=' . $i . '">' . $i. '</a> -';
}
$return .= '</div>';
return $return;
}
And... just to keep to the right forum, I do have a block code snippet for a random image, using the same database:
global $scripturl;
$query = db_query(
"SELECT file, gallery_id
FROM gallery
ORDER BY rand() LIMIT 1", __FILE__, __LINE__);
$randomrecord = mysql_fetch_assoc($query);
$rfile = $randomrecord['file'];
$thumb = "t_$rfile";
$pic = $randomrecord['gallery_id'];
echo '<center><a href="' . $scripturl . '?page=7;pic=' . $pic . '"><img src="/album/' . $thumb . '" border="0" alt="" /></a></center>';
Again, you'll want to replace page=7 with your actual page number.
At the moment, only admins and global moderators can do any adding, editing or deleting. I'll probably eventually be expanding it so that users can add their own images, but I may make that a completely separate gallery. I just got some ideas today that I have to contemplate for a while.
This would really only be good for people who are starting with a small image gallery. Uploading hundreds of images, one at a time, would be a real pain. But I thought someone might get some use from it and maybe someone else could come up with a mass import script for it.
hi jp
great work!
i have a script for images available which should be fairly simple to integrate into SMF, maybe it will help wit ur project
ill pm u the details :)
I like your site map. I gotz to get me one of those ;)
The big one or the little "Contents" block?
The big one is just a php article. I would have made it an html article, but I wanted to have the current membership count on there without having to constantly update it.
The little Contents block is just an html block. Nothing fancy. I chose that instead of using the site map block thing because I wanted more control over it... and because I made it before the site map block was available. ;) I am thinking that I should change the -- at the beginnings of lines to bullets like are in the userbox, though. Consistency and all that. Mostly, though the little one is a temporary thing for me to be able to get to pages easily. Eventually, all that will be in drop-down menus.
akulion, I'd love to see what you have. :)
both, but Im gonna have to make one of those php pages for my site. Sometimes I even forget everything on the site :o
did you use SSi for the forum members count? happen to know the code off the top of your head?
I didnt mean to hijack your thread... sorry.
It's okay. :)
Actually, it's not even SSI for the number of members. I just started with
global $modSettings;
and used
$modSettings['totalMembers']
where I wanted the number to print out. Here's the whole sentence where I used it:
echo '<p><a href="index.php?action=forum"><b>Forums</b></a> - active discussion with ' . $modSettings['totalMembers'] . ' members.'
I know what you mean about forgetting what you have. At the current site (which I'm switching to SMF/TP), the members seem to forget there's anything but the message board. That's a main reason for changing everything -- so I can keep the rest of the site in front of the members' faces. :)
i tried out the gallery didn't really work well for me. I added the tables added a new php article and changed all the page=7 to my page # pretty much everything you said.
Problems I have are:
When I try to upload an image it renames the image to t_a_1.jpg t_a_2.jpg etc. So I then just tried to manually upload the images to my album folder and rename them to t_a_1.jpg etc.... They then display but they don't resize or anything, they show in there full size and push each other off the page.
Dunno if I'm doing something wrong or what but just thought I'd let you know xD
QuoteSo I then just tried to manually upload the images to my album folder and rename them to t_a_1.jpg etc....
Actually, the script renames the files to a_1.jpg and then it creates a thumbnail named t_a_1.jpg. If you're going to do it by hand, then you'll have to create your own thumbnails in addition to uploading the files. Which pretty much negates the point of the script. I got tired of creating thumnails. :)
Quotepretty much everything you said.
It's gotta be all or nothing. "Pretty much" won't work.
QuoteI had my site password protected, but undid it so people could see the image gallery. This site is far, far from done. Smiley You won't be able to see the admin functions, but you can see what a user would see.
Not sure if it have some thing to do with that im on remote connection, but i cant get in to your site or image gallery, I get a popup with a question for username and password :-\
I know. I needed to protect it again. Sorry. I'm really close to it going "live" and I don't want the members to see it before it's ready. It's all supposed to be a big surprise. :-)
Edited to add:
It just occurred to me that I used the same type of code at my existing site. It's not TP (or even SMF, for that matter), but it's the same structure as is on my new SMF/TP site, so if you wanted to get an idea of what it looks like, you can. I just modified the code from my TP page to put it on a stand-alone php page.
http://www.morethanspike.com/images.php
Quote from: JPDeni on November 11, 2006, 04:30:13 AM
QuoteSo I then just tried to manually upload the images to my album folder and rename them to t_a_1.jpg etc....
Actually, the script renames the files to a_1.jpg and then it creates a thumbnail named t_a_1.jpg. If you're going to do it by hand, then you'll have to create your own thumbnails in addition to uploading the files. Which pretty much negates the point of the script. I got tired of creating thumnails. :)
Quotepretty much everything you said.
It's gotta be all or nothing. "Pretty much" won't work.
Well now that I know t_a_...jpg is the thumbnails I'm guessing it is just the images not uploading for me, hense why the thumbnails don't display ;p ... and yes I did check the permissions xD So I dunno.... Doesn't really matter to me I found another script anyways, just mentioned it incase it wasn't just me being dumb doing something wrong ;p
JPDeni,
Although the image (a_1.jpg) and thumbnail (t_a_1.jpg) are in the correct image directory and all fields were filled in before uploading, the image itself will not display. All that displays is the category name (Test). http://www.marscafe.com/moxforum/index.php?page=8 (http://www.marscafe.com/moxforum/index.php?page=8)
Below is the code for the 2 mysql tables. They are both populated with the one record that corresponds to the 'Test Image'.
Quote
CREATE TABLE `gallery` (
`gallery_id` int(6) unsigned zerofill NOT NULL auto_increment,
`gallery_cat_id` int(11) default NULL,
`title` varchar(255) default NULL,
`description` text,
`file` text,
`date` int(10) default NULL,
PRIMARY KEY (`gallery_id`)
);
CREATE TABLE `gallery_cats` (
`gallery_cat_id` int(11) unsigned zerofill NOT NULL auto_increment,
`gallery_cat` varchar(255) default NULL,
`sort_order` int(4) default NULL,
`father` int(10) default NULL,
PRIMARY KEY (`gallery_cat_id`)
);
Any idea what is wrong?
With thanks.
My fault. I should have had a variable for the URL for the picture. Since there wasn't much interest in this before, I didn't worry much about it. :)
Go through the script and find the references to /album/ in the img src tags. Change that to the directory where your images are.
If more people seem to want this, I'll go back and change it to a variable to be set at the beginning of the script.
JP,
Made the change as you suggested and that solved the problem.
QuoteIf more people seem to want this, I'll go back and change it to a variable to be set at the beginning of the script.
I am surprised that interest is not keen. Your gallery is very easy to use and straightforward while being flexible if you want to "get inside" and make some simple modifications.
Thank you for sharing your code.
PS// a useful first upgrade would be if you would allow users to post (with a limit) images and also be able to delete them.
marzi
aka chef mars
I've thought about adding an image upload thing for users, but just haven't done it yet. Actually, for my purposes, I've got some very specific things in mind to make it specific to my site. I just haven't done it yet. :) After I wrote mine, I found out that Bloc is planning to make a TP gallery, so I'm sorta waiting to see what it looks like and how I can tweak it to do my will. ;D
I think part of the reason that most folks aren't interested in this is that they like the galleries that count the number of views and allow for comments and ratings and that sort of thing. I don't like those, so I'd just have to remove them from any script that I use.
Glad it's been of use to you, marzi. :)
$directory = '/path/to/your/image/directory';
this URL or Physical path?
Quotethis URL or Physical path
It's the physical path. Not URL. This is where the script writes the files.
Thanks for the answer!
I create tables in my DB
Create php article with your code
replace page=7 to match whatever the page number is that I use
replace /path/to/your/image/directory to my path
And that does not work.... see attache
Where I am mistaken? :-\ :'(
PS Sorry for my english...
Your english is fine. It's much better than my Russian! ;D
I really don't know what the problem is. You have uploaded images, right? :)
yes I upload pictures through FTP in album folder.
I should see something, upload menu or images?
:-\
I shall wait tinyportal v.1.0... I hope TP 1.0 will released very soon. :)
I cant upload any images, I cant see upload admin panel
and I dont understand where is I wrong...
:( :'(
I find where i whong!
in my profile Primary Membergroup set not administrator
administrator be set in Additional Membergroups
I set Administrator in Primary Membergroup and gallery now is work
:)
Great Thanks for help!
I'm so glad it's working for you. :) I probably ought to have set up the permissions differently, but at the time I wrote that, I didn't understand how they worked. I really didn't intend to give it to anyone else.
thanks for you help!
but i have another problem: pictures uploaded in album folder not displayed in gallery
I can see categories, but cant see pictures...
The only thing I can suggest is that you look to be sure that the path to your directory is right an that you've got the correct URL to the directory, too. Look at all the places where it says "album/" in my code and change that to the name of your directory.
peeper,
Here is what I am using. I had a bit of a problem also getting the images to display and I am sure it was because of the the final / needed at the end of the URL syntax. I replaced all occurrences of /album/ with the URL
PATH
$directory = '/home/mydomain/public_html/moxforum/Themes/default/gallery';
URL
http://www.mydomian.com/moxforum/Themes/default/gallery/
Yeeehaaaa!
Thank ALL!
It was wrong path.
:)
JPDeni Thanks for code! :)
it's realy nice gallery!
Thanks to marzi for sharing her fix for it. :)
I think u should mod this up JP and release on SMF
otherwise it would be a Jem lost!
The trouble is that it is dependent upon having TP. This couldn't be just installed on SMF.
demo links are dead. Can someone put up another one please?
I'm not going to read through the whole thing to find out which links are dead, but the original one -- the first time this script was used -- is at http://www.morethanspike.com/index.php?page=7 which isn't dead at all.
thanks for the link =)