Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
I'm new to CouchCMS and I've successfully embedded a YouTube video in a page using shortcodes. I then added a new shortcode handler in kfunctions.php to load a thumbnail image that when clicked opens a video in a lightbox.

Code: Select all
      $html =<<<EOS
      <iframe width="560" height="315" src="https://www.youtube.com/embed/$video" frameborder="0" allowfullscreen data-basicLightbox data-id="1"></iframe>
      <a href="#" style="" data-show-id="1"><img width="240" height="200" alt="some text" src="images/video-thumb.jpg"/></a>
      EOS;


This works, my only issue is that the admin user can't change the thumbnail image without editing the code in kfunctions.php. Is it possible to set this up in such a way that the user can change the thumbnail image in admin?
I believe it is certainly possible, because shortcodes have full access to context with other editable fields. Perhaps, if you set up another editable of type image and make uploaded image auto-cropped and such (by associating it with an editable of type thumbnail or by directly instructing the image editable to be cropped) then that image's path will be read in kfunctions.php programmatically and added to generated code. I haven't used that kind of shortcode myself, so don't have an example, unless I code it from scratch. Sorry about that. Maybe admin has something to share?
Thanks trendoman for those ideas. Also it looks like I could pass the thumbnail path as a parameter.
NickW wrote: Thanks trendoman for those ideas. Also it looks like I could pass the thumbnail path as a parameter.

Welcome :) Keep me posted if you need something advanced.
4 posts Page 1 of 1