Adding class to first image

jeremy's Avatar


10 Apr, 2012 06:19 AM

I've hacked the "slideshow" displayer to show images in a better custom slideshow for mobile devices. I need the first image to apply "class="current" to the first image on page load. Any help here?

  1. 1 Posted by thomas on 20 Apr, 2012 10:15 PM

    thomas's Avatar

    hi jeremy,

    I don't know if I got it right, maybe you can try to add something like

    if ($totalFiles == 1){
        $image = str_replace(' />', ' class="current" />', $image);

    right before

    switch ( $data['type'] )
    in the slideshow plugin. This will add a class="current" to the first image.


  2. Support Staff 2 Posted by Mikael on 23 Apr, 2012 08:02 AM

    Mikael's Avatar

    It might be easier to just do this with javascript. Something like:

    jQuery(".slideshow .file:first-child").addClass("current");

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac