/*Plugin Name: Image Uploader
Plugin URI: http://hirewordpressexperts.com
Description: This plugin allows you to upload an image and associate it with a post so that it can be reused in your WP theme.
Author: Nikita
Version: 1.1
Author URI: http://hirewordpressexperts.com*/
add_action('publish_post', 'publish_fun');
add_action('publish_page', 'publish_fun');
add_action( 'save_post', 'publish_fun');
add_action( 'save_page', 'publish_fun');
function publish_fun()
{
//echo "nikita";
//print_r($_REQUEST);
$find_url=$_REQUEST['upload_image1'];
update_option("cnel123",$find_url);
global $post;
$post_id = get_the_ID();
$file = $_REQUEST['file'];
$pid1=$post_id;
update_option("cnel_post",$pid1);
$file=explode("/", $find_url);
foreach($file as $file_name)
{
}
if($find_url)
{
$up=wp_upload_dir();
//for medium resize image
$file_name=$up['path']."/".$file_name;
$temp_n1=$up['url']."/".$file_name;
$crop_height=get_option("mediumresize");
list($width, $height, $type, $attr) = getimagesize($file_name);
$crop_width=$width;
$org_height=$height;
$file_type= explode('.', $file_name);
$file_type = $file_type[count($file_type) -1];
$file_type=strtolower($file_type);
$original_image_size = getimagesize($file_name);
$original_width = $original_image_size[0];
$original_height = $original_image_size[1];
if($file_type=='jpg')
{
$original_image_gd = imagecreatefromjpeg($file_name);
}
if($file_type=='gif')
{ $original_image_gd = imagecreatefromgif($file_name);
}
if($file_type=='png')
{
$original_image_gd = imagecreatefrompng($file_name);
}
//for percent and pixels
$resample_pp=get_option("ps1");
if($resample_pp==1)
{
$val_of_perc=$crop_height;
//update_option("abc",$resample_pp);
$crop_height=($crop_height/100)*$org_height;
//update_option("nisha",$crop_height);
$crop_width=($val_of_perc/100)*$width;
}
if($resample_pp==2)
{
//update_option("abc",$resample_pp);
$perc=($crop_height/$org_height)*100;
$crop_width=($perc/100)*$width;
}
//finish pixel and percent
$cropped_image_gd = imagecreatetruecolor($crop_width, $crop_height);
$wm = $original_width /$crop_width;
$hm = $original_height /$crop_height;
$h_height = $crop_height/2;
$w_height = $crop_width/2;
if($original_width > $original_height )
{
$adjusted_width =$original_width / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;
imagecopyresampled($cropped_image_gd ,$original_image_gd ,-$int_width,0,0,0, $adjusted_width, $crop_height, $original_width , $original_height );
}
elseif(($original_width < $original_height ) || ($original_width == $original_height ))
{
$adjusted_height = $original_height / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;
imagecopyresampled($cropped_image_gd , $original_image_gd ,0,-$int_height,0,0, $crop_width, $adjusted_height, $original_width , $original_height );
}
else
{
imagecopyresampled($cropped_image_gd , $original_image_gd ,0,0,0,0, $crop_width, $crop_height, $original_width , $original_height );
}
$get_file=explode("/", $find_url);
foreach($get_file as $get_file_name)
{
}
$get_name=explode(".", $get_file_name);
$dest =$up['path']."/".$get_name[0]."_medium.".$get_name[1];
$source_crop_medium=$dest;
//update_option("a2",$source_crop_medium);
$var_d="mid_r_".$pid1;
update_option($var_d,$dest);
imagejpeg($cropped_image_gd ,$dest,100);
// postmeta for original
$var_u="upload".$pid1;
$temp_o=$up['url']."/".$get_name[0].".".$get_name[1];
update_option("original_image",$temp_o);
update_post_meta($pid1,"large_image",$temp_o);
//finish post meta
//for small resize image
$crop_height=get_option("smallresize");
list($width, $height, $type, $attr) = getimagesize($file_name);
$crop_width=$width;
$org_height=$height;
$file_type= explode('.', $file_name);
$file_type = $file_type[count($file_type) -1];
$file_type=strtolower($file_type);
$original_image_size = getimagesize($file_name);
$original_width = $original_image_size[0];
$original_height = $original_image_size[1];
if($file_type=='jpg')
{
$original_image_gd = imagecreatefromjpeg($file_name);
}
if($file_type=='gif')
{ $original_image_gd = imagecreatefromgif($file_name);
}
if($file_type=='png')
{
$original_image_gd = imagecreatefrompng($file_name);
}
//for percent and pixels
$resample_pp=get_option("ps4");
if($resample_pp==1)
{
$val_of_perc=$crop_height;
//update_option("abc",$resample_pp);
$crop_height=($crop_height/100)*$org_height;
//update_option("nisha",$crop_height);
$crop_width=($val_of_perc/100)*$width;
}
if($resample_pp==2)
{
//update_option("abc",$resample_pp);
$perc=($crop_height/$org_height)*100;
$crop_width=($perc/100)*$width;
}
//finish pixel and percent
$cropped_image_gd = imagecreatetruecolor($crop_width, $crop_height);
$wm = $original_width /$crop_width;
$hm = $original_height /$crop_height;
$h_height = $crop_height/2;
$w_height = $crop_width/2;
if($original_width > $original_height )
{
$adjusted_width =$original_width / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;
imagecopyresampled($cropped_image_gd ,$original_image_gd ,-$int_width,0,0,0, $adjusted_width, $crop_height, $original_width , $original_height );
}
elseif(($original_width < $original_height ) || ($original_width == $original_height ))
{
$adjusted_height = $original_height / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;
imagecopyresampled($cropped_image_gd , $original_image_gd ,0,-$int_height,0,0, $crop_width, $adjusted_height, $original_width , $original_height );
}
else
{
imagecopyresampled($cropped_image_gd , $original_image_gd ,0,0,0,0, $crop_width, $crop_height, $original_width , $original_height );
}
$get_file=explode("/", $find_url);
foreach($get_file as $get_file_name)
{
}
$get_name=explode(".", $get_file_name);
$dest =$up['path']."/".$get_name[0]."_small.".$get_name[1];
$source_crop_small=$dest;
$var_d="small_r_".$pid1;
update_option($var_d,$dest);
imagejpeg($cropped_image_gd ,$dest,100);
//crop medium
$crop_pp=get_option("ps2");
$crop_ww=get_option("ps3");
// Original image
$up=wp_upload_dir();
$filename=$source_crop_medium;
//update_option("a3",$filename);
$var_u="upload".$pid1;
update_option($var_u,$filename);
//$filename = $find_url;
//$saveto = WP_CONTENT_DIR."/uploads/2011/09".$get_name[0]."_medium_crop.".$get_name[1];
$saveto = $up['path']."/".$get_name[0]."_medium_crop.".$get_name[1];
$temp_n2 = $up['url']."/".$get_name[0]."_medium_crop.".$get_name[1];
update_option("medium_crop",$temp_n2);
update_post_meta($pid1,"medium_image",$temp_n2);
$var_d="mid_c_".$pid1;
update_option($var_d,$saveto);
// Get dimensions of the original image
list($current_width, $current_height) = getimagesize($filename);
//percent or pixel
$cr_h=get_option("mediumhight");
$cr_w=get_option("mediumwidth");
if($crop_pp==1)
{
//update_option("abc",$resample_pp);
$crop_height1=($cr_h/100)*$current_height;
}
if($crop_ww==1)
{
//update_option("nisha",$crop_height);
$crop_width1=($cr_w/100)*$current_width;
}
if($crop_pp==2)
{
//update_option("abc",$resample_pp);
$crop_height1=$cr_h;
}
if($crop_ww==2)
{
//update_option("nisha",$crop_height);
$crop_width1=$cr_w;
}
//finish percent or pixel
// The x and y coordinates on the original image where we
// will begin cropping the image
$top = (($current_height-$crop_height1)/2);
$left = (($current_width-$crop_width1)/2);
/*update_option("chkw",$current_width);
update_option("chkh",$current_height);
update_option("chkw1",$crop_width1);
update_option("chkh1",$crop_height1);
update_option("chkhl",$left);
update_option("chkht",$top);*/
// This will be the final size of the image (e.g. how many pixels
// left and down we will be going)
$crop_height = $crop_height1;
$crop_width =$crop_width1;
// Resample the image
$canvas = imagecreatetruecolor($crop_width, $crop_height);
$current_image = imagecreatefromjpeg($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagejpeg($canvas, $saveto, 100);
//crop small
$crop_pp=get_option("ps5");
$crop_ww=get_option("ps6");
// Original image
$up=wp_upload_dir();
$filename=$source_crop_small;
//$saveto = WP_CONTENT_DIR."/uploads/2011/09".$get_name[0]."_small_crop.".$get_name[1];
$saveto = $up['path']."/".$get_name[0]."_small_crop.".$get_name[1];
$temp_n3 = $up['url']."/".$get_name[0]."_small_crop.".$get_name[1];
update_option("small_crop",$temp_n3);
$pid1=$post_id;
update_option("post_id12",$pid1);
update_post_meta($pid1,"small_image",$temp_n3);
$var_d="small_c_".$pid1;
update_option($var_d,$saveto);
// Get dimensions of the original image
list($current_width, $current_height) = getimagesize($filename);
//percent or pixel
$cr_h=get_option("smallhight");
$cr_w=get_option("smallwidth");
if($crop_pp==1)
{
//update_option("abc",$resample_pp);
$crop_height1=($cr_h/100)*$current_height;
}
if($crop_ww==1)
{
//update_option("nisha",$crop_height);
$crop_width1=($cr_w/100)*$current_width;
}
if($crop_pp==2)
{
//update_option("abc",$resample_pp);
$crop_height1=$cr_h;
}
if($crop_ww==2)
{
//update_option("nisha",$crop_height);
$crop_width1=$cr_w;
}
//finish percent or pixel
// The x and y coordinates on the original image where we
// will begin cropping the image
$top = ($current_height-$crop_height1)/2;
$left = ($current_width-$crop_width1)/2;
// This will be the final size of the image (e.g. how many pixels
// left and down we will be going)
$crop_height = $crop_height1;
$crop_width =$crop_width1;
update_option("apple123","nikita");
/*//unlink files
$img_path=$up['path']."/".$get_name[0]."_small.".$get_name[1];
update_option("apple",$img_path);
update_option("apple123","nikita");
if(file_exists($up['path']."/".$get_name[0]."_small.".$get_name[1]))
{
unlink($img_path);
}
$img_path=$up['path']."/".$get_name[0]."_medium.".$get_name[1];
if(file_exists($up['path']."/".$get_name[0]."_medium.".$get_name[1]))
{
unlink($img_path);
}
//finish unlink*/
// Resample the image
$canvas = imagecreatetruecolor($crop_width, $crop_height);
$current_image = imagecreatefromjpeg($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
imagejpeg($canvas, $saveto, 100);
$img_path=$up['path']."/".$get_name[0]."_small.".$get_name[1];
update_option("apple",$img_path);
update_option("apple123","nikita");
if(file_exists($up['path']."/".$get_name[0]."_small.".$get_name[1]))
{
unlink($img_path);
}
$img_path=$up['path']."/".$get_name[0]."_medium.".$get_name[1];
if(file_exists($up['path']."/".$get_name[0]."_medium.".$get_name[1]))
{
unlink($img_path);
}
}
}
register_activation_hook(__FILE__,'resample_activate');
function resample_activate()
{
$cr_h1=get_option("smallhight");
$cr_w1=get_option("smallwidth");
$small_resize=get_option("smallresize");
$resize_wh=get_option("mediumresize");
$medium_height1=get_option("mediumhight");
$medium_width=get_option("mediumwidth");
if(!$small_resize)
{
update_option("smallresize","57");
update_option("ps4",2);
}
if(!$medium_height1)
{
update_option("mediumhight","180");
update_option("ps2",2);
}
if(!$medium_width)
{
update_option("mediumwidth","250");
update_option("ps3",2);
}
if(!$cr_h1)
{
update_option("smallhight","57");
update_option("ps5",2);
}
if(!$cr_w1)
{
update_option("smallwidth","100");
update_option("ps6",2);
}
if(!$resize_wh)
{
update_option("mediumresize","180");
update_option("ps1",2);
}
}
add_action( 'init', 'init_fun' );
function init_fun()
{
$id1=get_option("post_id12");
if($id1)
{
$t1=get_option("medium_crop");
update_post_meta($id1,"medium_image",$t1);
$t2=get_option("original_image");
update_post_meta($id1,"large_image",$t2);
$t3=get_option("small_crop");
update_post_meta($id1,"small_image",$t3);
$t4=get_option("medium_resample");
//update_post_meta($id1,"medium_image",$t4);
$t5=get_option("small_resample");
//update_post_meta($id1,"small_resample",$t5);
//update_option("post_id12","0");
}
}
add_action('save_post','save_post_fun');
function save_post_fun($p_idd)
{
//echo $p_idd;
}
add_action('admin_menu','myplugin_menu6');
function myplugin_menu6()
{
add_menu_page("","Image Uploader ",8,__FILE__);
add_submenu_page(__FILE__,"Settings","Settings",10,__FILE__,"fun_settings");
}
function fun_settings()
{
include("settings.php");
}
add_action( 'admin_init', 'upload_admin_init' );
function upload_admin_init()
{
add_meta_box('ep_admin_meta_box', __('Upload Image'), 'upload_fun', 'post', 'advanced', 'high');
add_meta_box('ep_admin_meta_box', __('Upload Image'), 'upload_fun', 'page', 'advanced', 'high');
}
function upload_fun()
{
include "design.php";
}
function my_admin_scripts()
{
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_register_script('my-upload', WP_PLUGIN_URL.'/hwe_imageupload_plug/my-script.js', array('jquery','media-upload','thickbox'));
wp_enqueue_script('my-upload');
}
function my_admin_styles()
{
wp_enqueue_style('thickbox');
}
$chk1=get_option("raju_cnel1");
//if($chk1=="yes")
{
$w=$_REQUEST['TB_iframe'];
update_option("tb",$w);
add_action('admin_print_scripts', 'my_admin_scripts');
add_action('admin_print_styles', 'my_admin_styles');
//wp_deregister_script('my-upload');
update_option("raju_cnel1","no");
}
?>
Nos membres | Animation Jeunesse Haut-Saint-François
Nos membres
Présentement, Animation Jeunesse du Haut-Saint-François fournit une aide et un support à cinq comités situés dans le municipalités de Weedon, Dudswell, Scotstown et Saint-Isidore de Clifton et ce, depuis 1993.
Nous visons à rejoindre tous les jeunes de 12 à 17 ans de la MRC du Haut-Saint-François.
Nous invitons tous les jeunes des municipalités environnantes à ce joindre à ces groupe pour participer aux activités.
Les autres municipalités qui ont de l’intérêt pour de tels comités sont priées de nous contacter. Tél. : 819 560-8486 poste 4 info@animationjeunessehsf.com