Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 2 [3] 4 5

Author Topic: Mods for sNews v1.4 here !!  (Read 35109 times)

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
Mods for sNews v1.4 here !!
« Reply #30 on: January 28, 2006, 05:32:29 am »

what are you using to resize the images? just gd or a ready-made script? seems nice! ;)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

albert

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 405
    • http://www.oswt.co.uk/
Mods for sNews v1.4 here !!
« Reply #31 on: January 28, 2006, 06:18:54 am »

Hi Stretsh

i have added this to the mods Image Resizing ::

I think this will be great as the img folder holds the image that goes to the left top of the artcal which is
sized via the css.

so intergation of this will be a plus to sNews. v1.4ceo and v1.3

look forward to seeing your code :)

Albert

Quote from: Stretsh
Done. Needs some tweeking, but it's working

www.stretsh-proof.com/snews
login rehuel, pw rehuel

The resize factor is set at 300 pixels. I'm going to make it that a variable, which can be set in the GLOBAL SETTINGS section.

This addition also checks to see if the uploaded file is really an image. If not, you get an error message.

Check it out, if you guys like it, let me know, then I will post the code for this addition to the snews.php somewhere suitable.
Logged
Albert
http://snews.awddesign.co.uk/snews/ site: v1.3
http://snews.awddesign.co.uk/           site: v1.2 http://www.awddesign.co.uk/
“Putting together the largest collection of sNews 1.5 designs. Coming very soon :)

Rehuel Lobato de Mesquita

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 61
Mods for sNews v1.4 here !!
« Reply #32 on: January 28, 2006, 07:33:56 pm »

No matter the size of the file you're uploading, it's being shrunk to your specified size, and then saved in the img folder.

Updated:
The snipplet checks to see if the sizes are smaller then what's pre-defined. If they are, it skips to the "successful" part, if not, it resizes the image to the predifined size.

find:
Code: [Select]
$s['rss_date_format'] = "l dS of F Y h:i:s A"; // RSS date format (DATE_RFC822)
Under, add :
Code: [Select]
$s['image_max_size'] = "300"; // The maximum width/height of an image after upload
find:
Code: [Select]
$upload_dir = s('image_folder') ."/";
copy ($_FILES['imagefile']['tmp_name'], $upload_dir .$_FILES['imagefile']['name']) or die ("Could not copy");
        echo "

" .l('operation_completed'). "

";

Replace with (I suggest you comment the original code out, just in case this is not what you want)
Code: [Select]
//insert by Stretsh
$upload_dir = s('image_folder') ."/";
$known_photo_types = array(
'image/pjpeg' => 'jpg',
'image/jpeg' => 'jpg',
'image/gif' => 'gif',
'image/bmp' => 'bmp',
'image/x-png' => 'png'
);
$gd_function_suffix = array(
'image/pjpeg' => 'JPEG',
'image/jpeg' => 'JPEG',
'image/gif' => 'GIF',
'image/bmp' => 'WBMP',
'image/x-png' => 'PNG'
);
if(!array_key_exists($_FILES['imagefile']['type'], $known_photo_types))
{
echo "File ".$_FILES['imagefile']['name']." is not a photo
";
}
else
{
$new_id = $_FILES['imagefile']['name'];
$filetype = $_FILES['imagefile']['type'];
$extention = $known_photo_types[$filetype];
$filename = $new_id.".".$extention;

copy($_FILES['imagefile']['tmp_name'], $upload_dir."/".$filename) or die ("Could not copy");

$size = GetImageSize( $upload_dir."/".$filename );
if (($size[0] > s('image_max_size')) || ($size[1] > s('image_max_size'))) {
if($size[0] > $size[1])
{
$pic_width = s('image_max_size');
$pic_height = (int)(s('image_max_size') * $size[1] / $size[0]);
}
else
{
$pic_width = (int)(s('image_max_size') * $size[0] / $size[1]);
$pic_height = s('image_max_size');
}

$function_suffix = $gd_function_suffix[$filetype];
$function_to_read = "ImageCreateFrom".$function_suffix;
$function_to_write = "Image".$function_suffix;

$source_handle = $function_to_read ( $upload_dir."/".$filename );
if($source_handle)
{
$destination_handle = ImageCreateTrueColor ( $pic_width, $pic_height );
ImageCopyResampled( $destination_handle, $source_handle, 0, 0, 0, 0, $pic_width, $pic_height, $size[0], $size[1] );
}
$function_to_write( $destination_handle, $upload_dir."/".$filename );
ImageDestroy($destination_handle );
}
echo "

" .l('operation_completed'). "

";
}
//end insert by Stretsh

I was tired as hell llast night, so still needs some tweaking. I got some work to do, so maybe later I'll look in to the tweaking part.

And I think you got your answer analyzerx: GD

Logged
Stretsh Out...

Procrastination is like masturbation. You do it till you figure out you're only screwing yourself!

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
Mods for sNews v1.4 here !!
« Reply #33 on: January 28, 2006, 08:20:51 pm »

One question though, stretsh... If uploading a smaller pic... Will that be enlarged to the same size as the others are shrunk to ? It seems that way, when I uploaded a smaller pic of myself, hehe.... Ah, thou beautiful son of a "ladydog" ;)
Logged
"It's only dead fish that goes with the flow... "
Updated

bryn

  • Hero Member
  • *****
  • Karma: 2
  • Posts: 934
    • http://www.cssugly.com
Mods for sNews v1.4 here !!
« Reply #34 on: January 28, 2006, 08:39:16 pm »

clever..I was thinking of asking the same question as Patric..enlarging certain types of images wouldn't be good for quality, and hence a waste of time if it does? good work though ;D
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
Mods for sNews v1.4 here !!
« Reply #35 on: January 28, 2006, 08:46:43 pm »

 *Patric slaps himself with a dead fish in the back of head*

Oh, yes... I did leave out that part, sorry stretsh... Really good work. I meant to write that in my first post, but forgot it ;).
Love this snippet, I've been loking for something like that. But as you can see, the code makes a smaller pic go up in size...Can you adjust that...perhaps...if I ask nicely...please ...;)
Logged
"It's only dead fish that goes with the flow... "
Updated

Rehuel Lobato de Mesquita

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 61
Mods for sNews v1.4 here !!
« Reply #36 on: January 28, 2006, 10:05:51 pm »

Yes true, I did not think of that one. I'll try to make it check first if the width/height of the pic is smaller then the given. If not, resize!

Give me a couple minutes, le me check this one
Logged
Stretsh Out...

Procrastination is like masturbation. You do it till you figure out you're only screwing yourself!

Rehuel Lobato de Mesquita

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 61
Mods for sNews v1.4 here !!
« Reply #37 on: January 28, 2006, 11:59:54 pm »

ok, I updated my previous code. Works now
Logged
Stretsh Out...

Procrastination is like masturbation. You do it till you figure out you're only screwing yourself!

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
Mods for sNews v1.4 here !!
« Reply #38 on: January 29, 2006, 07:34:33 am »

Quote from: Stretsh
ok, I updated my previous code. Works now

Stretch this is an awesome piece of code! ^_^
Congratulations! :)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
Mods for sNews v1.4 here !!
« Reply #39 on: January 29, 2006, 08:02:13 am »

Great. will try this afternoon ;). Thanks for this great contribution, stretsh....
Logged
"It's only dead fish that goes with the flow... "
Updated

Rehuel Lobato de Mesquita

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 61
Mods for sNews v1.4 here !!
« Reply #40 on: January 29, 2006, 06:17:23 pm »

Thanx Dude
Logged
Stretsh Out...

Procrastination is like masturbation. You do it till you figure out you're only screwing yourself!

bryn

  • Hero Member
  • *****
  • Karma: 2
  • Posts: 934
    • http://www.cssugly.com
Mods for sNews v1.4 here !!
« Reply #41 on: January 30, 2006, 08:05:15 am »

yep thanks for the code Stretsh..good work! ;D
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

albert

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 405
    • http://www.oswt.co.uk/
Mods for sNews v1.4 here !!
« Reply #42 on: February 01, 2006, 10:35:16 am »

Hi Stretsh

great scrpt you have done for sNews, Good Work.

Just one more thing that will need to be added will be the 'Lang' to be added.

ie
Quote
or die ("Could not copy");
etc etc

Eny one that has tested this so fare should give us some more feed back on this code :)


Albert

Logged
Albert
http://snews.awddesign.co.uk/snews/ site: v1.3
http://snews.awddesign.co.uk/           site: v1.2 http://www.awddesign.co.uk/
“Putting together the largest collection of sNews 1.5 designs. Coming very soon :)

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
Mods for sNews v1.4 here !!
« Reply #43 on: February 01, 2006, 09:21:23 pm »

I'm thinking of making a collection of snews with mods so users can try them out...
so If stretsh doesn't mind me adding his to it (all credits go to each who made the mod and will ask each on indevidually! ^_^)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Rehuel Lobato de Mesquita

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 61
Mods for sNews v1.4 here !!
« Reply #44 on: February 02, 2006, 04:44:03 am »

Dude, I don't even mind if my name is not mentioned (ok, well, maybe a little)

I am just very happy that I could contribute to this marvelous project!
Logged
Stretsh Out...

Procrastination is like masturbation. You do it till you figure out you're only screwing yourself!
Pages: 1 2 [3] 4 5