First of all, I am not a php programmer. In fact today was the first time I ever tried to write a single php statement. So beware that what follows might be utter rubish!
Having said that, I wanted to be able to handle keywords which consists of several individual words. Out-of-the-box 4images would treat the keyword <Summer evening> as two separate words. In English where a lot of phrases are made up of individual words without a dash or anything in between, this feels awkward.
I have spent hours scanning the forum, and it seems that others have asked for this without it being resolved.
My solution builds upon Rembrandt's IPTC V.1.7.6 Suchfelder erweiterung mod:
http://www.4homepages.de/forum/index.php?topic=21141.0Do not attempt this mini-mod-attempt without first having applied Rembrand's mod.
Here goes
a) The idea is to convert spaces to underscores when keywords come into the system and convert underscores back to spaces when keywords are displayed (the keywords table strip underscores away, so a keyword <Summer_Evening> will be stored there as <SummerEvening> which is pretty perfect as it prevents hits if people search for <Summer>).
b) keywords can come into the system from IPTC tags (which corresponds to the tags displayed by e.g. Vista or Photoshop) - see edit 2) below
c) keywords can be entered directly on the "edit image" form in the APC. I don't know how to intercept that... if anyone has an idea, please shout!
d) keywords are shown on the detail screen as clickable hyperlinks - see edit 1) below
1) Edit includes\functions.php.
Find
if (!empty($image_row['image_keywords'])) {
$split_keywords = explode(" ", $image_row['image_keywords']);
$keywords = "";
foreach ($split_keywords as $key => $val) {
$keywords .= (($keywords != "" ) ? ", " : "")."<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".urlencode($val))."\">".format_text($val, 2)."</a>";
}
Replace by
if (!empty($image_row['image_keywords'])) {
$split_keywords = explode(" ", $image_row['image_keywords']);
$keywords = "";
foreach ($split_keywords as $key => $val) {
$oldval = $val;
if ($val != "") {
$val = str_replace('_', ' ', $val);
}
$keywords .= (($keywords != "" ) ? ", " : "")."<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_keywords=".urlencode($oldval))."\">".format_text($val, 2)."</a>";
}
2) Edit \admin\checkimages.php
Find
$iptc_keywords_default = 0; //auto insert keyword from IPTC (0 or 1)
Replace with
$iptc_keywords_default = 1; //auto insert keyword from IPTC (0 or 1)
Find
$caption = ($iptc_description && isset($iptc['2#120'][0])) ? $iptc['2#120'][0] : "";
$keywords = "";
if ($iptc_keywords && isset($iptc['2#025']))
{
foreach ($iptc['2#025'] as $val)
{
$keywords .= (($keywords != "" ) ? " " : "").$val;
}
Replace with
$caption = ($iptc_description && isset($iptc['2#120'][0])) ? $iptc['2#120'][0] : "";
$keywords = "";
if ($iptc_keywords && isset($iptc['2#025']))
{
foreach ($iptc['2#025'] as $val)
{
$val = str_replace(' ', '_', $val);
$keywords .= (($keywords != "" ) ? " " : "").$val;
}
3) This works if you get your pictures into the database by
a) FTP'ing the images to your site
b) running a "check images" from the APC
4) This also works if you type in keywords with underscores in place. So say you wanted to type in the tag <Summer Evening>, you would type it in as <Summer_Evening>. I have not been able figure out how to get checkimage.php to automatically replace <Summer Evening> with <Summer_Evening> for you, so unless someone can point me in the right direction (?), I can't help here. As I aim to have my images tagged before upload, it's not a huge problem for me, but it would be nice to find a solution.
As I started by saying, this is my first attempt at modifying 4images or anything else in php. It is entirely possible that this "mod" will break something or that there are side effects which I haven't considered. So use it at your own peril. Having said that, if you do use it, please let me know if it also works acceptable for you or if you run into problems.