Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1223696

    Hi,

    I want to add a shortcode to block external media to the “Link portfolio item to external URL” to load. Right now if I put a Youtube link to that, it will pop up in an iframe and will display the video directly.

    What I want to do is to put a shortcode like this: [borlabs-cookie id=”youtube” type=”content-blocker”]URL[/borlabs-cookie] so it will display a content blocker if they haven’t agreed to the privacy settings in the beginning. Reference on how it looks like is here: https://borlabs.io/borlabs-cookie/iframe-demo/

    If I add the shortcode directly there, the youtube video will not load at all.

    Could you help me with this?

    Best,
    Indra

    #1225453

    Hey forgottensky,

    Thank you for the inquiry.

    We are not really sure how the borlabs content block works but you can add an overlay above the portfolio item using a filter. Maybe you can create a script that removes the overlay when the user opt in to play the video or click the button in the overlay.

    You can add this in the functions.php file:

    add_filter('avf_portfolio_custom_overlay', function($overlay, $entry) {
    	$id = $entry->ID;
    	$custom_link = get_post_meta( $id, '_portfolio_custom_link', true ) != '' ? get_post_meta( $id, '_portfolio_custom_link_url', true ) : false;
    	if($custom_link) {
    		$overlay .= "<div class='grid-entry-privacy-overlay'><span>You shall not pass!<span></div>";
    	}
    	return $overlay;
    }, 10, 2);
    
    

    .. then use this css code to style the overlay a bit:

    
    .grid-entry-privacy-overlay {
        display: table;
    	position: absolute;
    	text-align: center;
    	width: 100%;
    	height: 100%;
    	background: rgba(0,0,0,0.3);
    }
    
    .grid-entry-privacy-overlay span {
    	display: table-cell;
    	vertical-align: middle;
    	color: #ffffff;
    	font-size: 2em;
    }
    

    You can also try and add the borlabs shortcode as the output of the overlay filter.

    Best regards,
    Ismael

    #1226541

    Hi Ismael,

    thanks for your reply! I tried your solution but it doesn’t really work in my context. Putting the shortcode as the output of the overlay didn’t work out as it throws out a lot of compiler error. I may try different methods but this is turning out more complicated than I thought.

    Thanks again for your time and help.

    Best,
    Indra

    #1227687

    Hi,

    What does the shortcode returns or renders when you add or embed it in a page? Did you wrap it in a do_shortcode function?

    // https://developer.wordpress.org/reference/functions/do_shortcode/

    What errors were thrown when you included the shortcode in the overlay? Please post it pastebin.com so that we can check it.

    Thank you for your patience.

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.