4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: RezaSalmanzadeh on December 10, 2005, 02:24:20 AM
-
[Mod] Resize wallpaper for restrain resize template.
By this mod you can restrain resize your template and create scroll at down your web pages for big pictures or wallpepars, install this mod is easy.
Just 5 files to edit:
/includes/functions.php
/lang/english/main.php
/templates/default(or template name)/media/gif.html
/templates/default(or template name)/media/jpg.html
/templates/default(or template name)/media/png.html
& create:
image.php
-------[installing]-------
Step 1.
Open /includes/functions.php
Find:
function get_media_code($media_file_name, $image_id = 0, $cat_id = 0, $image_name = "", $mode = "", $show_link = 0, $detailed_view = 0) {
global $site_template, $site_sess, $lang, $mode;
if (!get_file_path($media_file_name, "media", $cat_id, 0, 0)) {
$media = "<img src=\"".ICON_PATH."/404.gif\" border=\"0\" alt=\"\" />";
$site_template->register_vars("iptc_info", "");
}
else {
$media_src = get_file_path($media_file_name, "media", $cat_id, 0, 1);
$file_extension = get_file_extension($media_file_name);
$media_icon = "<img src=\"".ICON_PATH."/".$file_extension.".gif\" border=\"0\" alt=\"".$image_name."\" />";
if ($show_link) {
$media_icon = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\">".$media_icon."</a>";
}
$width_height = "";
$width = "";
$height = "";
$iptc_info = "";
$src = (!file_exists($media_src) && file_exists(preg_replace("/\/{2,}/", "/", get_document_root()."/".$media_src))) ? preg_replace("/\/{2,}/", "/", get_document_root()."/".$media_src) : $media_src;
if ($image_info = @getimagesize($src, $info)) {
$width_height = " ".$image_info[3];
$width = $image_info[0];
$height = $image_info[1];
if ($detailed_view && isset($info['APP13'])) {
$iptc_array = get_iptc_info($info['APP13']);
$bgcounter = 0;
foreach ($iptc_array as $key => $val) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$site_template->register_vars(array(
"iptc_value" => $val,
"iptc_name" => $lang['iptc_'.$key],
"row_bg_number" => $row_bg_number
));
$iptc_info .= $site_template->parse_template("iptc_bit");
}
}
}
$site_template->register_vars(array(
"media_src" => $media_src,
"media_icon" => $media_icon,
"image_name" => $image_name,
"width_height" => $width_height,
"width" => $width,
"height" => $height,
"iptc_info" => $iptc_info
));
$media = $site_template->parse_template("media/".$file_extension);
}
return $media;
}
Replace with:
function get_media_code($media_file_name, $image_id = 0, $cat_id = 0, $image_name = "", $mode = "", $show_link = 0, $detailed_view = 0) {
global $site_template, $site_sess, $lang, $mode, $lang;
if (!get_file_path($media_file_name, "media", $cat_id, 0, 0)) {
$media = "<img src=\"".ICON_PATH."/404.gif\" border=\"0\" alt=\"\" />";
$site_template->register_vars("iptc_info", "");
}
else {
$media_src = get_file_path($media_file_name, "media", $cat_id, 0, 1);
$file_extension = get_file_extension($media_file_name);
$media_icon = "<img src=\"".ICON_PATH."/".$file_extension.".gif\" border=\"0\" alt=\"".$image_name."\" />";
if ($show_link) {
$media_icon = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\">".$media_icon."</a>";
}
$width_height = "";
$width = "";
$height = "";
$iptc_info = "";
$src = (!file_exists($media_src) && file_exists(preg_replace("/\/{2,}/", "/", get_document_root()."/".$media_src))) ? preg_replace("/\/{2,}/", "/", get_document_root()."/".$media_src) : $media_src;
if ($image_info = @getimagesize($src, $info)) {
$width_height = " ".$image_info[3];
$width = $image_info[0];
$height = $image_info[1];
if ($width > $lang['wm_width'] || $height > $lang['wm_height']){
$set = 'true';
}else{
$notset = 'true';
}
if ($detailed_view && isset($info['APP13'])) {
$iptc_array = get_iptc_info($info['APP13']);
$bgcounter = 0;
foreach ($iptc_array as $key => $val) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$site_template->register_vars(array(
"iptc_value" => $val,
"iptc_name" => $lang['iptc_'.$key],
"row_bg_number" => $row_bg_number
));
$iptc_info .= $site_template->parse_template("iptc_bit");
}
}
}
$site_template->register_vars(array(
"set" => $set,
"notset" => $notset,
"lang_wm_gloss" => $lang['wm_gloss'],
"media_src" => $media_src,
"media_icon" => $media_icon,
"image_name" => $image_name,
"width_height" => $width_height,
"width" => $width,
"height" => $height,
"iptc_info" => $iptc_info
));
$media = $site_template->parse_template("media/".$file_extension);
}
return $media;
}
function php_image_creator($width_1, $height_1, $n_width, $n_height, $image, $quality){
header('Content-type: image/jpeg');
$image_p = imagecreatetruecolor($n_width, $n_height);
$image_q = imagecreatefromjpeg($image);
imagecopyresampled($image_p, $image_q, 0, 0, 0, 0, $n_width, $n_height, $width_1, $height_1);
$picture = imagejpeg($image_p, null, $quality);
return $picture;
}
Step 2.
Open /lang/english/main.php
Find:
?>
Add before:
//-----------------------------------------------------
//--- Wallpaper MOD -----------------------------------
//-----------------------------------------------------
$lang['wm_gloss'] = "This picture is a wallpaper for view real size please click on picture.";
$lang['wm_width'] = "800"; // This number is width standard for your picture in pixel.
$lang['wm_height'] = "600"; // This number is height standard for your picture in pixel.
$lang['wm_quality'] = "80"; // This number is quality your picture in pixel, best quality is (60 - 100).
You can change width, height or quality wallpapers by 3 array $lang['wm_width'], $lang['wm_height'] and $lang['wm_quality'] (default is 800 X 600).
Step 3.
Open /templates/default(or template name)/media/gif.html
Find:
<!-- Template file for GIF Files -->
<img src="{media_src}" border="1" alt="{image_name}"{width_height} /><br />
Replace with:
<!-- Template file for GIF Files -->
{if set}<b>{lang_wm_gloss}</b><br /><br /><a target="_blank" alt="{image_name}" href="{media_src}"><img src="image.php?v={media_src}" border="1" alt="{image_name} :: Wallpaper"/></a><br />{endif set}
{if notset}<img src="{media_src}" border="1" alt="{image_name}"{width_height}/><br />{endif notset}
Also for jpg.html & png.html
Step4 .
Create an empty php file by name "image.php" and copy below code to it, then copy "image.php" to root directory (4image folder).
<?php
/********************************************************************
* ~~~{ In the name of god }~~~ *
* *
* 4images - A Web Based Image Gallery Management System *
* ------------------------------------------------------------ *
* *
* File: image.php *
* Final Revision: 2005/08/31 09:12:21 PM *
* Copyright: (C) 2005 Reza Salmanzadeh *
* Email: Reza_664@yahoo.com *
* Web Site: www.Taklyrics.com *
* Scriptversion: 0.1 *
* *
********************************************************************
* *
* *
* ()()()() ()()()() ()()()() ()() *
* () () () () () () () () *
* () () () () () () () *
* ()()()() ()()() () ()()()()() *
* () () () () () () () *
* () () () () () () () () *
* () () ()()()() ()()()() () () *
* ----------------------------------------------------- *
* *
*******************************************************************/
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
$image = $HTTP_GET_VARS['v'];
$maxwidth = $lang['wm_width'];
$maxheight = $lang['wm_height'];
$quality = $lang['wm_quality'];
if ($image != ""){
$size = getimagesize("$image");
$height_1 = $size[1];
$width_1 = $size[0];
if ($height_1 > $maxheight){
$n_height = $maxheight;
$percent = ($size[1] / $n_height);
$n_width = ($size[0] / $percent);
}else if ($width_1 > $maxwidth){
$n_width = $maxwidth;
$percent = ($size[0] / $n_width);
$n_height = ($size[1] / $percent);
}
if ($n_height > $maxheight){
$n_height = $maxheight;
$percent = ($size[1] / $n_height);
$n_width = ($size[0] / $percent);
}else if ($n_width > $maxwidth){
$n_width = $maxwidth;
$percent = ($size[0] / $n_width);
$n_height = ($size[1] / $percent);
}
php_image_creator($width_1, $height_1, $n_width, $n_height, $image, $quality);
}
?>
// For use this mod php version of server just support "gd" !
Good luck!
Reza Salmanzadeh :wink:
-
Can we see an example, or a screenshot or something?
-
you can see this mod to below links :
http://www.singersfan.com/gallery/details.php?image_id=2434
http://www.danceage.com/gallery/img2199.htm
-
Hello RezaSalmanzadeh & V@no: This Mod works fine, but the only problem here is images appear to be broken if the names of images contains spaces. For exapme: Mypic.jpg show up in detail page, but My pic.jpg or My%20pic.jpg doesnt show up in detail page even though it shows up in Admin CP. Any idea Guys? :roll:
-
in image.php try to replace
$image = $HTTP_GET_VARS['v'];
with:$image = urldecode($HTTP_GET_VARS['v']);
-
It is still V@no. It doesnt work :roll:
-
Hi,
is this the same as this....-> http://www.4homepages.de/forum/index.php?topic=9885.0 ????
-
It is still V@no. It doesnt work :roll:
And what the error logs say?
can we see it in action?
-
JensF : sorry, i cant read that language :|
V@no: There are no the error logs. There is no error at all except some of images (just some) dont show in detail page. Then i have figured out that all images' names with spaces have that problem. As JensF gave the link above. It appears to be like this in detail page:
http://www.web-upload.de/templates/default/media/jpg.html
-
It appears to be like this in detail page:
http://www.web-upload.de/templates/default/media/jpg.html
What I ment, was the page where the images is not shown...not the template (the problem is not in the template)
-
I got the same problem
-
the same here.....no one an idea????
-
Hallo,
ersteinmal muss ich sagen, echt ein super Mod.
Aber wie kann man beim neuem Fenster das sich beim klicken auf das verkleinerte Bild eine Rechtsklicksperre einfügen?
Ist bei der Hauptseite ja auch.
Ich will nämlich das die bilder über den Downloadbutten runtergeladen wird und nciht mit "Speichern unter". Wird nämlich nciht in der Statistik erfasst!!!
ODer habt ihr dafür eine andere Lösung?
z.B. das die Originalgröße nicht geöffnet wird sondern beim runterladen bekommt man die Originalgröße erst! Wie geht das?
Schonmal Danke
-
Thanks Reza,
it's working fine :D.
@JensF : hier kann man direkt aufs Bild klicken und die links fallen weg.
-
Hallo,
ersteinmal muss ich sagen, echt ein super Mod.
Aber wie kann man beim neuem Fenster das sich beim klicken auf das verkleinerte Bild eine Rechtsklicksperre einfügen?
Ist bei der Hauptseite ja auch.
Ich will nämlich das die bilder über den Downloadbutten runtergeladen wird und nciht mit "Speichern unter". Wird nämlich nciht in der Statistik erfasst!!!
ODer habt ihr dafür eine andere Lösung?
z.B. das die Originalgröße nicht geöffnet wird sondern beim runterladen bekommt man die Originalgröße erst! Wie geht das?
Schonmal Danke
Diese Arbeit kannst Du Dir sparen, da man die Rechtsklicksperre sehr sehr einfach umgehen kann, besser wäre es, wenn das Bild gar nicht gross angesehen werden kann, nur heruntergeladen werden! --> der Klick in der details.html wäre somit hinfällig!
-
does this mod use a lot of server resource? :?
-
so from what i understood. when i upload image (800x600 (for example)) to my gallery, it will automaticly rezise image on template (500x350 for example) and automaticly adds link on image when pressing on image to go to original (800X600) image ????
-
Yep, you got it correct :D
:idea: since this MOD opens images in a ordinary new browser window, u can also use a JavaScript so that it opens in a new " chromeless window " window (i.e., without the toolbar, address bar etc....)
modify something like: (in your template/media/jpg.html and others if needed)
<td width="32" height="32" align="center" valign="middle"><a alt="{image_name}" href="{media_src}" onClick="NewWindow(this.href,'name','800','600','yes');return false"><img src="image.php?v={media_src}" border="0"/></a></td>
add: (in your template/header.html )
<script type="text/javascript">
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
</script>
also a nice idea to keep all JavaScripts in an external ,js file so that your HTML files on site looks clean.....
use something like
<script type="text/javascript" src="{template_url}/images/file_name.js"></script>
:D
-
DEMO: [/color] www.hotDT.com (http://www.hotDT.com)
-
This Mod looks great. Can it be used to open the original file "size" and not be restricted to the "wallpaper" sizings? Forgive me if I'm missing the point.
I too have the same problem as JensF and Vampireus where the images appear as thumbnails until you go to the Details page where no image appears at all. I have tried to translate the German posts here but cannot find one that relates to this problem.
Any help would be appreciated. Cheers
-
nznevin if you do all the steps correctly u should be getting it working fine... :wink:
I guess u have made a mistake in step 3
This Mod looks great. Can it be used to open the original file "size" and not be restricted to the "wallpaper" sizings? Forgive me if I'm missing the point.
you mean, on the details page, when clicking the image (resized image) ? if yes: ofcourse :wink:
check a demo here www.hotdt.com (http://www.hotdt.com) to see what this mod can achieve… (ps, a little modification: http://www.4homepages.de/forum/index.php?topic=10720.msg61386#msg61386 is needed to get exactly this result as on the site.)
-
Hi,
I'm a total noob with this gallery sistem, first time I'm using it, and I love it already.
This mod was the exact thing that I was looking for.
I have a fixed site width, with about 500px space for the image to be displayed (inside detail file).
I have quite a few images that are bigger that the window, so a "open in a new window" is the exact thing I was looking for.
But I've enocuntered a problem. Two actually.
First thing it, I get the link to open in a new window on ALL my pictures, even those that are smaller then 500px. I'd imagine that the link to full sized picture would only appear when needed (for pictures that are bigger then 500px). Right?
Further more, I don't get the link on a picture, I get the picture name with link attached (meaning, I can't click on the picture, since there's no link attached to it. Above the image I get the image name with the link).
And the last thing, when my images are above 500px limit, the script doesn't resize them, the image just dissapears.
What am I doing wrong?
I have GD2 installed on my server.
I should also mention I'm a total noob in php, but I learn really fast.
Please help.
TIA!!
Mat
-
I love this mod, but I'm experiencing a couple of glitches that I've been unable to work out. Some of the time it is working properly, but most of the time when I click on the details page I get the full size image with an empty 'box' on top of it, or either both sizes of images are displayed.
ex:
(http://img.photobucket.com/albums/1003/kashmore/misc/th_ex01.jpg) (http://img.photobucket.com/albums/1003/kashmore/misc/ex01.jpg) (http://img.photobucket.com/albums/1003/kashmore/misc/th_ex02.jpg) (http://img.photobucket.com/albums/1003/kashmore/misc/ex02.jpg)
If I hit refresh a few times it will sometimes correct itself, though sometimes it does not.. I've cleared the cache, and have no clue where to proceed from here. Any ideas?
-
I'm having the same trouble as Kashmore above. It works fine except sometimes it displays the smaller resized version and also the original sized version on the same page.
-
hey folks i cant see my images in details.php
http://www.wallpaperize.com/img32.htm
i think i have a problem with jpg.html.. http://www.wallpaperize.com/image.php?v=http://www.wallpaperize.com/wallpaper/data/categories/Girls/papers/Adriana_Lima_1272003103001PM616.jpg
it is obviously abnormal url..
how can i solve it?
-
anyone alive in there?
-
Your server does not have GD2 installed.
-
I love this mod, but I'm experiencing a couple of glitches that I've been unable to work out. Some of the time it is working properly, but most of the time when I click on the details page I get the full size image with an empty 'box' on top of it, or either both sizes of images are displayed.
ex:
(http://img.photobucket.com/albums/1003/kashmore/misc/th_ex01.jpg) (http://img.photobucket.com/albums/1003/kashmore/misc/ex01.jpg) (http://img.photobucket.com/albums/1003/kashmore/misc/th_ex02.jpg) (http://img.photobucket.com/albums/1003/kashmore/misc/ex02.jpg)
If I hit refresh a few times it will sometimes correct itself, though sometimes it does not.. I've cleared the cache, and have no clue where to proceed from here. Any ideas?
I'm having the same exact problem!!
EDIT: I think have been able to fix the problem as described above in the quoted post by kashmore.
1) Open up the modded /includes/functions.php
2) Find the following code located in that file. (It's actually within the function get_media_code):
if ($width > $lang['wm_width'] || $height > $lang['wm_height']){
$set = 'true';
}else{
$notset = 'true';
}
3) .. And REPLACE all of that with:
if ($width > $lang['wm_width'] || $height > $lang['wm_height']){
$set = 1;
$notset = 0;
}else{
$set = 0;
$notset = 1;
}
4) Save the file!
Let me know if it works people. I tried this with 1.7.2
-
Erstmal Dank für dieses MOD.
Bin vollends zufrieden damit.
Nur eine Frage. Wie kann ich das Bild so vergrößern, dass nicht nur das Bild im neuen Fenster aufgeht, sondern das Bild mittig auf schwarzem Hintergrund erscheint?
Danke GizMoh
-
Is this mod for upload and link? or just the upload only?
-
Hi,
No disrespect to the author but I found this mod to be a little too slow, having to resize and compress the original image in real time (even on a T2300 1.66GHz Core Duo processor that I did my testing on). To rectify this, I simply and ONLY modify the three files:
jpg.html
png.html
gif.html
...and replace the original code:
<!-- Template file for GIF Files -->
<img src="{media_src}" border="1" alt="{image_name}"{width_height} /><br />
with this instead:
<!-- Template file for GIF Files -->
<a target="_blank" alt="{image_name}" href="{media_src}"><img src="{media_src}" border="1" alt="{image_name} {"width="800" height="600"}></a><br />
It's nothing fancy but it works just the same but faster.
Note:
Don't challenge me as I suck writing web pages.... but I did this based on trial and error and plagerize codes from other websites :)
-
Greetings. At me here such problem (in figure below). Not everywhere pictures are displayed. That is where that they are, and where that is not present. In what there can be a problem? In advance thanks!
-
and if you right click on the broken image, go to properties, copy the address of the image (in FireFox this process could be simplifyed by right click -> "Copy Image Location"), then paste it into browser's address bar and hit enter, will it show you any error messages?
-
and if you right click on the broken image, go to properties, copy the address of the image (in FireFox this process could be simplifyed by right click -> "Copy Image Location"), then paste it into browser's address bar and hit enter, will it show you any error messages?
No if to press this beaten image in a following window the high-grade image opens.
-
Will this mod work for externally linked images
-
How can select the file types that i need to show as a wallpaper?
-
this mod works well.. but when the image is loaded in a new window.. it shows the actual location of the image in the adress bar.. is there any way to hide that or mask the url as 4images does by default??
-
Test success: http://www.wallpaper-pack.com
Thank you!
-
Can we see an example, or a screenshot or something?
V@no this mod is a lovely one, unfortunately it does not seem to be working anymore (cannot find the required code to replace).. maybe its because the funcation.php file got updated in the 1.7.6 version... will it possible to update this MOD for us?
Thanks