Sage 9 - Missing protocol using blade

Hi, I’m trying to echo out a source using {{ $video }} but the link missing the http/(s) protocol.
Tried {!! $video !!} as well but no luck … If I do var_dump($video) from the controller i can see the protocol there, so my thought is that blade are doing something with the source before it’s echo.

Please tell me it’s a quick fix for this one …

Before anyone can help, we need to see your code (blade view and controller)


    poster="{{ $amp_data->video[$row]->poster }}">
    <source src="{{ $amp_data->video[$row]->webm }}" type="video/webm" />
    <source src="{{ $amp_data->video[$row]->mp4 }}" type="video/mp4" />

    <div fallback>
        <p>This browser does not support the video element.</p>


namespace App\Controllers;

use Sober\Controller\Controller;

class PageTemplateGutenberg extends Controller
     * AMP
     * Iterating while loop and picks up the data for AMP Version.

    public function AmpData()
        $data = (object) array();

        if (have_rows('amp_modules')) {
            $row = 0;

            while(have_rows('amp_modules')) : the_row();
                if (get_row_layout() === 'video') {
                    $data->video[$row] = (object) array(
                        'mp4'    => get_sub_field('amp_modules_video_mp4')['url'],
                        'webm'   => get_sub_field('amp_modules_video_webm')['url'],
                        'poster' => get_sub_field('amp_modules_video_poster')['sizes']['medium_large']

                    // var_dump($data->video[$row]->webm);
                } else if (get_row_layout() === 'booking') {
                    $data->booking[$row] = (object) array(
                        'title'   => get_sub_field('amp_modules_booking_title'),
                        'btn_txt' => get_sub_field('amp_modules_booking_btn_text')
                } else if (get_row_layout() === 'slider') {
                    $data->slider[$row] = (object) array(
                        'slides' => get_sub_field('amp_modules_slides')
                    // var_dump(get_sub_field('amp_modules_slides'));
                } else if (get_row_layout() === 'accordion') {
                    $data->accordion[$row] = (object) array(
                        'toggle_txt'     => get_sub_field('amp_modules_accordion_btn_txt'),
                        'content'        => get_sub_field('amp_modules_accordion_content'),
                        'read_more_txt'  => get_sub_field('amp_modules_accordion_content_read_more_txt'),
                        'read_more_link' => get_sub_field('amp_modules_accordion_content_read_more_link')
                } else if (get_row_layout() === 'full_site') {
                    $data->full_site[$row] = (object) array(
                        'btn_txt'  => get_sub_field('amp_modules_full_site_txt'),
                        'btn_link' => get_sub_field('amp_modules_full_site_link')


        return $data;

What does @dump( $amp_data ) show?

See below, no protocol

object(stdClass)#7736 (5) { ["video"]=> array(1) { [0]=> object(stdClass)#8167 (3) { ["mp4"]=> string(58) "//localhost:3000/wp-content/uploads/2018/12/mov_bbb.mp4" ["webm"]=> string(66) "//localhost:3000/wp-content/uploads/2019/01/big_buck_bunny.webm" ["poster"]=> string(85) "//localhost:3000/wp-content/uploads/2018/12/At-Six-xmas-gift-card-1500-768x516.jpg"

Can we take a look at var_dump( $amp_data ) or print_r( $amp_data ) to confirm the scheme is actually in the data in the database?

The good news is that the scheme isn’t technically necessary. Scheme-relative URLs are actually valid and browser will re-use whatever the current scheme is in the browser bar. But it’s irritating to have data removed from fields.

{{ }} just runs the string through PHP’s htmlentities. Unless you need to escape html for security reasons and want output that looks like <b>&amp this</b> instead of & this, use {!! !!} instead.

I’ve never seen the Controller strip the scheme. In this case I’d take a look at ACF and experiment with running get_sub_field('amp_modules_video_mp4')['url'] outside of Controller and Blade to see what’s returned.

This topic was automatically closed after 42 days. New replies are no longer allowed.