Support

Account

Home Forums General Issues How to add captions to videos for ADA compliance?

Solving

How to add captions to videos for ADA compliance?

  • For ADA compliance, we need to have captions in our videos. Is that possible? I don’t see a field for the captions file.

  • Captions would be part of the video and not something you can add using ACF.

  • Captions are separate files, usually with vtt or srt extension these days.

  • if you are looking for this for use in an oembed field, this uses the built in oembed feature of WP. As far as I know, WP does not have the ability you’re looking for. https://wordpress.org/support/article/embeds/

    In order to add anything to the output of an oembed provided by WP you would need to create filters on the output. This can be done using the embed_oembed_html and/or oembed_result hooks. Both of these hooks supply the HTML for the embed and you would need to parse the HTML and insert additional elements as needed.

    If you can do that you could use a different ACF field to hold something to be inserted. However, there would not be much available in to the filter to allow you to match up the video being shown with any additional fields that you want to pull information from. You would need to somehow use the url of the video to find out what field that url was pulled from and then find the field that has your additional data.

  • This is what I would do if I needed to do this. (after doing a little research)

    I would use a URL field for the video and not an oembed field.
    I would add an additional file field to upload the captions

    In my PHP code I would do

    
    <?php 
      $shortcode = '[video src="'.get_field('video_url_field').'"]';
      $shortcode .= '<track srclang="en" label="English" kind="subtitles" src="'.get_field('captions-file-field').'" default>';
      $shortcode .= '[/video]';
      echo do_shortcode($shortcode);
    ?>
    

    See this https://stphnwlkr.co/web/adding-video-to-wordpress/

    It might be possible to use an oembed field if you get the value without formatting so that ACF does not do the formatting of the field.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.