Member
Member
Goodfreephotos   27-03-2018, 00:17
#1

Hi,
I want to change the alt text location for my thumbnails.
Using printLatestImages() , the alt text is the same as the title but I want to change it, Iooked up a really old thread:

http://forum.zenphoto.org/discussion/1719/changing-alt-text-for-images

I looked through template function but I cannot find where:

alt=""

is located. The documentation did not help much, anyone know where that line of code is located?

Administrator
Administrator
acrylian   27-03-2018, 08:47
#2

It is located within the function printImageStatistic() of the image_album_statistics plugin within the lines 577-590 depending on what options used. It uses the core object model and therefore is a bit different.

Recommended way for customisations: Copy, rename and modify the function (e.g. mytheme_printImageStatistics()) and place it within your theme's function.php.

Member
Member
Goodfreephotos   27-03-2018, 19:39
#3

Found it, not very good with syntax though.

If I just want to add "free photo" at the end of the alt text

echo '[img]' . html_encode(pathurlencode($image->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '[/img]getTitle()) ."\" />\n";

How would I just append "free photo" at the end of the title for the alt text, keep getting the wrong syntax.

Administrator
Administrator
acrylian   28-03-2018, 07:12
#4

Appending text is quite basic like this html_encode($image->getTitle()) . ' free photo'

Member
Member
Goodfreephotos   28-03-2018, 17:33
#5

I get an error when I do:

echo '[img]' . html_encode(pathurlencode($image->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '[/img]getTitle()) . 'free photo' "\" />\n";

is there some kind of backslash that I need to do?

Administrator
Administrator
acrylian   28-03-2018, 18:58
#6

You have an issue with your quotes here. A double quote is wrong. At the end it should be something like . 'free photo"'. " />\n";. You can also just end like . 'free photo" />'; The \n part is just for code formatting a new line and has no other functionality.

Member
Member
Goodfreephotos   28-03-2018, 20:56
#7

Both:

echo '[img]' . html_encode(pathurlencode($image->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '[/img]getTitle()) . 'free photo"'\" />\n";

and

echo '[img]' . html_encode(pathurlencode($image->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '[/img]getTitle()) .'free photo"\" />'\n";

Give errors, I've tried a lot of different interations, can't get it to work.

Administrator
Administrator
acrylian   29-03-2018, 08:06
#8

Well, you didn't pay atention to the details. Look at your quotes. Whatever you open, you also need to close. Especially the last one is really wrong. This is really PHP basics, sorry…

Try this:
`echo '[img]' . html_encode($image->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE)) . '[/img]getTitle()) . 'free photo"'. " />\n";

If it doesn't work the error might also be in another line already.

Member
Member
wibbi   05-04-2018, 18:05
#9

A better way is to duplicate the function you need, give him a new name, edit it and use it.

You can find the file and point of an function in the Zenphoto docs.
http://docs.zenphoto.org/
Use the search-box at top-right. (works only with function names like "printLatestImages" or "LatestImages").

The function printLatestImages() only includes an another function. The function printImageStatistic().
Get to the file which the functions are included via SFTP.
Duplicate both functions and rename it in the same file and near to the originals (below is a good place). Rename it unique, because a function getImageStatistic() is always available, but included not what you need.
In this case you need not a "print" (echo), but a "get" (return).
function getLatestImages_myname()
function getImageStatistic_myname()
Use the second in the first.
Yet you can edit the function as you need.
In this function is it a little bit complicated to change from "print" to "get". The simpler way is just to edit the part with "alt" and don't rename the function to "get". The better way is you change the first "echo" to a variable like "$returnvar =" and all other "$returnvar .=" and below the last echo make a "return $returnvar;".
Yet you can use the function in your theme and change the string, which is returned by the function, before it is printed (echo) with PHP replace. Search a unique substring in the string and replace it.
str_replace
substr_replace
preg_replace
Use it like ``````

In your case:

Administrator
Administrator
acrylian   05-04-2018, 18:21
#10

Duplicate both functions and rename it in the same file and near to the originals (below is a good place). Rename it unique, because a function getImageStatistic() is always available, but included not what you need.

Duplicate and rename yes, but don't place it in the same file! Never edit core or official files if you can avoid it. Better: Copy it to your theme's functions.php and use it there (don't forget to check for plugin dependencies though!).

The "weird" mixture of single and double quotes is primarily because of the source code view only\n line break that only works with double quotes. (And yes it is a bit more weird than it needs to be ;-)).

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.