hi,
i have a filter that i wrote for zenphoto 1.2.9. it used to make good use of the `filterAccentedCharacters` function that was in the filter-zenphot_seo.php file. it is now located in the zenphoto_seo.php file. nothing has really changed except that few hebrew characters have been added to the specialchars array. anyway the call to the function in my filter is not working anymore. if i comment the call, everything is fine. i even tried to comment everything in the function but still the call is not going through. i am a bit puzzled. any idea on what's going on ?
of course i have enabled the zenphoto_seo plugin to be able to mak a call to the function.
thanks for your help,
frank
Comments
BTW, you are not really using the function correctly (although it should work so long as the plugin is enable.)
What you should be using is the seoFrindly() function. That function uses whatever is configured for the "seoFriendly" filter, including a default translation should none be configured.
`$imgname = filterAccentedCharacters($imgname);`
and the execution of the code stops on this instruction. there is no error, the execution just stops.
if i edit the `filterAccentedCharacters` function in the zenphoto_seo.php file and add an echo instruction such as `echo 'here we go';` right at the beginning of the function, nothing prints. it looks like it does not even enter the `filterAccentedCharacters` function.
hopefully, this helps a bit. with the version 1.2.9, activating a plugin or a filter was enough for all its functions to be known everywhere, i am now wondering if since then one has to add a specific instruction so that functions of one plugin can be used in another one ?
If not, then be sure you are really getting to the line in your plugin.
But better anyway is that you use the standard seoFriendly() function as described above.
right now what i need is a seo friendly version of the image title which can contain accented characters (french, spanish...), double dashes or spaces.
basically if the image title is "René Hood" i want to turn it into "rene-hood". looking at the `filterAccentedCharacters` function, it seems to me that's what it does. i understand that it is anyhow a filter applied to the `seoFriendly` function and therefore i should only call `seoFriendly`.
using the zenpage theme, i made a simple test. i added this code right after `` tag:
`
<?php
$test='René Hood';
$seotest=seoFriendly($test);
echo 'seo-ed test: ' . $seotest;
?>
`
the result is "RenHood" and not "rene-hood". am i missing something ?
inside the `seoFriendly` function in the functions.php file i have looked at the `has_filter` test and it looks like the `filterAccentedCharacters` filter is not applied (looks like we only go through the else - basic cleanup - instruction).
note the lower case option in the zenphoto_seo plugin is checked.
But just for curiosity, why are you stripping the diacritical marks from the title? The filter is back-end only because it is normally used only for converting file/folder names so that both the URL looks better and filesystems which do not support those characters will work.
now to answer your curiosity... basically i have different albums. in every album, the photos have a generic filename and a number that differentiate them (e.g. burma-1.jpg, burma-2.jpg and so on).
i have read that for image search, the filename is important and it is better to have some kind of explicit name such as jumping-cat.jpg rather than burma-34.jpg. well that's is what i read. as google is very opaque, i do not know to what extent this is true.
anyway i had in mind to change the name of my pictures and have it reflect the title of the pic. i could have simply renamed all pics once for all but i have so much more on my harddrive that are waiting to be uploaded that i thought it would maybe be better to keep things how they are and just write a filter that does that.
i did with ZP 1.2.9 and it works ok. you can check that on my burmese gallery for instance.
i want to port this feature to the latest ZP1.4 version and that's where i am... working on it.
doing things this way is the solution i have chosen which might not be the best. maybe there is already a function that i haven't seen which does that. if you have any feedback i'll be glad to hear it even if it is to tell me that this filter thing sounds stupid.
so basically i went back to the basics and here is my "stripped" plugin
`
<?php
$plugin_is_filter = 5|CLASS_PLUGIN;
$plugin_description = gettext("Plugin/Filter description");
$plugin_author = "frankm";
$plugin_version = "1.4";
zp_register_filter('load_request', 'filterImageReq');
function filterImageReq($allow) {
echo 'inside the filter <br />';
return $allow;
}
?>
`
looks to me it is very similar to the seo_locale filter that is applied to the same load_request. anyway, i never get the message "inside the filter" printed on the very top of my page. i'm stuck as i can't get the filter to be simpler.
We manage to hide that most times as Setup will also insure the value in the option is correct. But of course if you are developing a plugin this is something you would need to know.
It is doing almost what you describe. But instead of using the title for the name it is just using seoFriendly() on the filename. If you are actually changing the filename of the image you should remember that there are database entries that have to get handled as well. This utility does take care of that.