styling printRandomImages, specifically <li> and <img>...

Hi,
when I use printRandomimages, I can assign a class to the "ul" tag, but not the "li", "a", or "img" tags... That is, not unless I go into template-functions.php and add the classes there. I have done this as shown in the code below. (added class="random one" to the "li" tag and "random pic" to the three "img" cases) Everything works fine, but I get a notice that 'a change has been detected, and while it may not be critical please run setup ASAP.' So I did some research and concluded that the recommended way of modifying the function is to leave template-functions.php in its original format, copy the function I want to the functions.php in the zenpage folder and modify it there. This did not work...
Please let me know how best to proceed. Thank you.
`

function printRandomImages($number = 5, $class = null, $option = 'all', $rootAlbum = '', $width = NULL, $height = NULL, $crop = NULL, $fullimagelink = false) {

if (is_null($crop) && is_null($width) && is_null($height)) {

$crop = 2;

} else {

if (is_null($width))

$width = 85;

if (is_null($height))

$height = 85;

if (is_null($crop)) {

$crop = 1;

} else {

$crop = (int) $crop && true;

}

}

if (!empty($class))

$class = ' class="' . $class . '"';

echo "

Comments

  • acrylian Administrator, Developer
    Please escape code in `backticks` or within the html element `code`. It was marked as spam because you didn't.

    Wou get a warning because you should NEVER modify core files. Instead create a custom function with another name (you can't have two functions with the same name naturally) of the one that does not fit your purpose, put it in your theme's functions.php (or create a plugin) and use that instead of the original. Also most functions have a get and print variant.
    The "get" one returns just the data you can create your own output with.

    But the question is why do you need classes on the li and img tags as you can address them via selectors as well? `ul.yourclass li { … }` and `ul.yourclass li img { … }`.
  • Thank you so much. I asked one question... got three answers! That's good stuff.
Sign In or Register to comment.