Alt Text in Image Block searchbable?
Permalink
Hello,
It seems, that the Alt-Text that I can enter with an Image Block is not searchable. Is there a way to change that behavior?
I have hundreds of images on my Website and only now I discovered that I can't search by these texts. I know that i could define a file attribute for this, but that would mean really lot of work to copy all these texts to the attribute. Also, if I use a file attribute, the same image would always have the same Alt-Text. But sometimes I use the image on different pages with with different Alt-Texts.
Thanks for your help!
Harald
It seems, that the Alt-Text that I can enter with an Image Block is not searchable. Is there a way to change that behavior?
I have hundreds of images on my Website and only now I discovered that I can't search by these texts. I know that i could define a file attribute for this, but that would mean really lot of work to copy all these texts to the attribute. Also, if I use a file attribute, the same image would always have the same Alt-Text. But sometimes I use the image on different pages with with different Alt-Texts.
Thanks for your help!
Harald
Thank you very much!
I wrote a simple controller.php with this content:
After reindexing it works perfectly!
Cheers
Harald
I wrote a simple controller.php with this content:
After reindexing it works perfectly!
Cheers
Harald
Hi, I've been looking to make images searchable in a photography site but haven't had any luck as yet.
Looked at the code above and wondered if you could tell me where I would implement this please.
Looked at the code above and wondered if you could tell me where I would implement this please.
Hi,
I finally got it. I placed it under the other public functions in the concrete/blocks/images/controller.php
It was calling an error for me so I used.
I reinstalled the block and rescanned the search index and it worked great.
I finally got it. I placed it under the other public functions in the concrete/blocks/images/controller.php
It was calling an error for me so I used.
public function getSearchableContent(){ return $this->altText; }
I reinstalled the block and rescanned the search index and it worked great.
Hi,
I am also having a similar problem. I attempted to place the code where I thought was needed but cannot get it to work. Either it does refresh the index and calls an error or it does nothing at all.
Could you let me know where you placed this code? It would help a bunch.
Sorry my skills are pretty light right now.
Thanks
I am also having a similar problem. I attempted to place the code where I thought was needed but cannot get it to work. Either it does refresh the index and calls an error or it does nothing at all.
Could you let me know where you placed this code? It would help a bunch.
Sorry my skills are pretty light right now.
Thanks
The best way to understand it is to look at an existing block such as the core content block (though many other blocks also implement getSearchableContent() ).
You have some choices:
1. Override the controller with a root level override and add your own version of getSearchableContent().
2. Create your own clone of the whole block under a new name, with your own version of getSearchableContent()
3. Create a new image block using something like Designer Content, though that will probably need some code tweaks once generated to do the above.
4. Make the change as a pull request on GitHub and hope it gets approved for subsequent version of c5.