4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: naimtaha on April 04, 2013, 09:02:48 PM

Title: [Mod] Link your images to external URL
Post by: naimtaha on April 04, 2013, 09:02:48 PM
Hello,


How i can link an image ( during image upload or after upload) to an external URLs.
i want the visitors to be able to click on the image and then directed to external website for more details.

i am using version 1.7.11.

Thank you guys for your help!

Naim


Title: Re: [Mod] Link your images to external URL
Post by: Rembrandt on April 07, 2013, 06:20:50 AM
Welcome to the Forum!

1.) Copy the File "install_weblink.php" from the Attachment in your Gallery "root", login as Admin, and call it to.

2.) search in includes/db_field_definitions.php "?>" and insert above:

$additional_image_fields['image_weblink'] = array($lang['image_weblink'], "text", 0);


3.) search in lang/your Lang/main.php "?>" and insert above:
(english)

 $lang['image_weblink'] = "Weblink: <span class=\"smalltext\">input without: http://<span>";

(deutsch)

 $lang['image_weblink'] = "Weblink: <span class=\"smalltext\">eingabe ohne: http://<span>";


4a.) search in includes/functions.php (for 4images 1.7.8 and newer):

  $site_template->register_vars(array(
    "image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view),
  ))

and repalce:

// #### Start Weblink ######  
  if(!empty($image_row['image_weblink'])){
    $weblink = str_replace("http://","",$image_row['image_weblink']);
    $weblink = "<a href=\"http://".$weblink."\">".get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view)."</a>";
  }else{
    $weblink = get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);
  }
  $site_template->register_vars("image",$weblink);
// #### End Weblink ######


4b.) search in includes/functions.php (for 4images 1.7.7 and older):

  $site_template->register_vars(array(
    "image_id" => $image_row['image_id'],

insert above:

// #### Start Weblink ######
    if(!empty($image_row['image_weblink'])){
    $weblink = str_replace("http://","",$image_row['image_weblink']);
    $weblink = "<a href=\"http://".$weblink."\">".get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view )."</a>";
  }else{
    $weblink = get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);
  }
// #### End Weblink ######

search some lines including:

"image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view),

and replace:

"image" => $weblink,


5.) search in member.php:

$value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];

and repalce:

// #### Start Weblink ######
//$value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
$value = (isset($HTTP_POST_VARS[$key])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
// #### End Weblink ######


6.) search in your Templates/member_uploadform.html:
Code: [Select]
{if captcha_upload}
insert above:
Code: [Select]
         <tr>
            <td class="row1" valign="top"><b>{lang_image_weblink}</b></td>
            <td class="row1">
              <input type="text" name="image_weblink" size="30" value="{image_weblink}" class="input">
            </td>
          </tr>

7.) search in your Templates/member_editimage.html:
Code: [Select]
             <textarea name="image_keywords" cols="30" rows="10" wrap="virtual" class="textarea">{image_keywords}</textarea>
            </td>
          </tr>
insert below:
Code: [Select]
         <tr>
            <td class="row1" valign="top"><b>{lang_image_weblink}</b></td>
            <td class="row1">
              <input type="text" name="image_weblink" size="30" value="{image_weblink}" class="input">
            </td>
          </tr>

mfg Andi
Title: Re: [Mod] Link your images to external URL
Post by: naimtaha on April 07, 2013, 10:18:53 PM
Thank you Rembrandt!

I modified all 7 files per your instruction below ( but i couldn't locate includes/db_ definitions.ph and modified db_field_ definitions.php instead.

when I called "install_weblink.php" and starts DB modification it comes with the following error messages:

DB Error: Bad SQL Query: ALTER TABLE 4images_images ADD `image_weblink` VARCHAR(64) NOT NULL DEFAULT ''
Duplicate column name 'image_weblink'
Error
  ALTER TABLE 4images_images ADD `image_weblink` VARCHAR(64) NOT NULL DEFAULT ''

please help....

Naim

Title: Re: [Mod] Link your images to external URL
Post by: Rembrandt on April 08, 2013, 05:18:32 AM
...
I modified all 7 files per your instruction below ( but i couldn't locate includes/db_ definitions.ph and modified db_field_ definitions.php instead.
There is ok..

...
when I called "install_weblink.php" and starts DB modification it comes with the following error messages:
...Duplicate column name 'image_weblink'
You can install the tablefield  "image web link" only one time.
You have called the "install_weblink" more as one time, there is ok so..

Title: Re: [Mod] Link your images to external URL
Post by: naimtaha on April 08, 2013, 10:03:14 AM
Thank you!

But nothing was changed I am still unable to add any web link to images!!

Regards,

Naim
Title: Re: [Mod] Link your images to external URL
Post by: Rembrandt on April 08, 2013, 06:07:36 PM
..But nothing was changed I am still unable to add any web link to images!!
..
You see not the new Field "Weblink" in your Upload or Edit form?
Then have you step 6-7.) in the wrong Template copied.

mfg Andi
Title: Re: [Mod] Link your images to external URL
Post by: diva78 on April 10, 2013, 02:33:53 PM
Hi,
thx a lot for your Mods, I love them!
After having put this one into my DB, the images in the detail template won't be shown. There is only th 404 image.
What have I done wrong?
Thanks for your help!
Title: Re: [Mod] Link your images to external URL
Post by: Rembrandt on April 10, 2013, 03:22:16 PM
Welcome to the Forum

I have updatet step 4.)

mfg Andi
Title: Re: [Mod] Link your images to external URL
Post by: diva78 on April 10, 2013, 06:38:52 PM
thx for your quick reaction. Sorry, that I've not mentioned it yet: I run 4Images 1.7.10, so I haven't seen any changes in the code. Right?
Title: Re: [Mod] Link your images to external URL
Post by: Rembrandt on April 10, 2013, 07:56:00 PM
Hi!
thx for your quick reaction. Sorry, that I've not mentioned it yet: I run 4Images 1.7.10, so I haven't seen any changes in the code. Right?
Sorry, but I had used a modified version of me.
I have again step 4a.) changed, now it works correct.
For your 4images version is the right step 4a.)

mfg Andi
Title: Re: [Mod] Link your images to external URL
Post by: diva78 on April 10, 2013, 08:41:49 PM
Great! That worked. I only changed the varchar(64) to varchar(400), cause my link was longer and so cut :x and put a "target=_blank" to the reference to open the link in new window...  
But again: thanks a lot!!!