Hi Joe,
Having a flag in the config file would be nice.
I did the necessary changes to have the image link to a url. The following are the changes I did. Two files were affected.
I hope this is considered useful and implemented in the core for version 2.4 (or before)
-----------------------------------------------------------------------------------------------
Change Item Image to URL
-----------------------------------------------------------------------------------------------
fa/inventory/manage/items.php
Insert in Line 54 right after: $Ajax->activate('details');
if (isset($_POST['url']) && $_POST['url'] != '')
{
$url = trim($_POST['url']);
if (strpos($url, 'http') !== false)
{
$stock_id = $_POST['NewStockID'];
$upload_file = 'Yes'; //Assume all is well to start off with
$filename = company_path().'/images';
if (!file_exists($filename))
{
mkdir($filename);
}
$filename .= "/".item_img_name($stock_id).".url";
$handle = fopen($filename, 'w');
fwrite($handle, $url);
$result=fclose($handle);
if (!$result)
{
display_error(_('The link could not be saved'));
$upload_file ='No';
}
}
}
--------------------------------------------------
~ Line 199 : REPLACE
$filename = company_path().'/images/'.item_img_name($_POST['NewStockID']).".jpg";
if (file_exists($filename))
unlink($filename);
WITH:
$filename = company_path().'/images/'.item_img_name($_POST['NewStockID']).".jpg";
if (file_exists($filename))
unlink($filename);
$filename = company_path().'/images/'.item_img_name($_POST['NewStockID']).".url";
if (file_exists($filename))
unlink($filename);
--------------------------------------------------
~ Line 276 : REPLACE
$filename = company_path().'/images/'.item_img_name($stock_id).".jpg";
if (file_exists($filename))
unlink($filename);
WITH:
$filename = company_path().'/images/'.item_img_name($stock_id).".jpg";
if (file_exists($filename))
unlink($filename);
$filename = company_path().'/images/'.item_img_name($stock_id).".url";
if (file_exists($filename))
unlink($filename);
-------------------------------------------------
around line 418 REPLACE:
// Add image upload for New Item - by Joe
file_row(_("Image File (.jpg)") . ":", 'pic', 'pic');
// Add Image upload for New Item - by Joe
$stock_img_link = "";
$check_remove_image = false;
if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/'
.item_img_name($_POST['NewStockID']).".jpg"))
{
// 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D.
$stock_img_link .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
"]' src='".company_path().'/images/'.item_img_name($_POST['NewStockID']).
".jpg?nocache=".rand()."'"." height='$pic_height' border='0'>";
$check_remove_image = true;
}
else
{
$stock_img_link .= _("No image");
}
WITH:
// URL link for images added by Carmelo Romano on 25/07/2013
$stock_img_link = "";
$check_remove_image = false;
url_row(_("Image Link") . ":", 'url', 'url');
if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/'
.item_img_name($_POST['NewStockID']).".url"))
{
$url="";
$filename=company_path().'/images/'.item_img_name($_POST['NewStockID']).".url";
$handle = @fopen($filename, r);
if ($handle) {
$url = fgets($handle, 1024);
}
if (!empty($url)) {
$stock_img_link .= "<a href='".$url."' target='_766266'>
<img id='item_img' alt = '[".$_POST["NewStockID"].".jpg"."]'
src='".$url."'"." height='$pic_height' border='0'><br>
Open image in New Window</a>";
$check_remove_image = true;
}
fclose($handle);
}
else
{
// Add image upload for New Item - by Joe
file_row(_("Image File (.jpg)") . ":", 'pic', 'pic');
// Add Image upload for New Item - by Joe
$stock_img_link = "";
$check_remove_image = false;
if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/'
.item_img_name($_POST['NewStockID']).".jpg"))
{
// 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D.
$stock_img_link .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
"]' src='".company_path().'/images/'.item_img_name($_POST['NewStockID']).
".jpg?nocache=".rand()."'"." height='$pic_height' border='0'>";
$check_remove_image = true;
}
else
{
$stock_img_link .= _("No image");
}
}
------------------------------------------------
fa/includes/ui/ui_input.inc
ADD:
//-----------------------------------------------------------------------------------
function url_cells($label, $name, $id="")
{
if ($id != "")
$id = "id='$id'";
label_cells($label, "<input type='text' name='$name' size='35' />");
}
function url_row($label, $name, $id = "")
{
echo "<tr><td class='label'>$label</td>";
url_cells(null, $name, $id);
echo "</tr>\n";
}
Regards, carmelo