Caption not showing up in image

Permalink 2 users found helpful
Hello

I'm new to C5 and have just taken over a site to look after. I'm doing OK except for one thing. I have a page of reviews which is created by image blocks. I can add a new block and see the image, which links to it's child page with no problem. But the alt text/caption does not show up. I've looked at the other block settings but it all looks identical. Any thoughts as to what might be the problem please?

 
defunct replied on at Permalink Reply
defunct
Could we see this live please to help diagnose the problem?
Mnkras replied on at Permalink Reply
Mnkras
Alt text is for people who have images disabled, or disabled people, it doesn't actually add anything under the image
ashdonite replied on at Permalink Reply
http://www.laviniabrown.co.uk/index.php/press/

Since this is a live site I don't really want to release the page with the missing text, but it's this page I need to add another review to. The new block with its image appears no problem - just no text.

I know alt text is normally for accessibility purposes but there are only four options to complete on the Edit box: image / image on state / image links to URL / Alt text/Caption. For the previous blocks it does appear that the alt text creates the block text, unless I am missing something - which I obviously am!

Thanks
melat0nin replied on at Permalink Reply
melat0nin
You need to edit the Image block's controller.php (first copy it from /concrete/blocks/image/ to /blocks/image/)

Here's what I did:

Just before this at around line 91:

$img .= "/>";


insert this:

$img .= "<div class=\"caption\">{$this->altText}</div></div>";


This will create a DIV with the class 'caption' below your image. You can style that whatever way you like.
juguerr replied on at Permalink Reply
Hi melat0nin,
I am really new in this. Where do I find the controller.php? and how so I copy it to the place you indicate?

Thank you,
Pritam replied on at Permalink Reply
You can find it within \yoursiteroot\concrete\blocks\image

to \yoursiteroot\blocks\image
juguerr replied on at Permalink Reply
Gracias/ Thank you Pritam
nickodalton replied on at Permalink Reply
nickodalton
here's the html5 way I did it (replacing existing code block in blocks/image/controller:

$img = "<figure><img border=\"0\" class=\"ccm-image-block\" alt=\"{$this->altText}\" src=\"{$relPath}\" {$sizeStr} ";//add figure html5
         $img .= ($align) ? "align=\"{$align}\" " : '';
         $img .= ($style) ? "style=\"{$style}\" " : '';
         if($this->fOnstateID != 0) {
            $fos = $this->getFileOnstateObject();
            if ($this->maxWidth > 0 || $this->maxHeight > 0) {
               $thumbHover = $ih->getThumbnail($fos, $mw, $mh);            
               $relPathHover = $thumbHover->src;
            } else {
               $relPathHover = $fos->getRelativePath();
            }
            $img .= " onmouseover=\"this.src = '{$relPathHover}'\" ";
            $img .= " onmouseout=\"this.src = '{$relPath}'\" ";
         }
         $img .= ($id) ? "id=\"{$id}\" " : "";


hope this helps someone on the search!
magpie replied on at Permalink Reply
Very useful, was searching how to show caption text beneath images. This HTML5 code does the job.
okapi replied on at Permalink Reply
okapi
For those who found this thread by searching for caption for images: there is free add-on available at the marketplace that does what the core image module is still lacking: "Lightboxed Image" with an optional lightbox.

http://www.concrete5.org/marketplace/addons/lightboxed-image...