• At this moment there is no way to change the parameters passed to vimeo.

    This means that for (badly configured) Vimeo accounts, the video title could be showing which you may not want.

    A filter for the url would allow a developer to change the url and add the parameters if necessary.

    This would also allow for making the url protocol relative which it currently isn’t.

    What I’m basically suggesting is changing:

    File: /src/CycloneSlider/Frontend.php
    Line: 146

    $slides[$i]['vimeo_embed_code'] = '<iframe id="'.$slider_html_id.'-iframe-'.$i.'" width="'.$slider_settings['width'].'" height="'.$slider_settings['height'].'" src="http://player.vimeo.com/video/'.$vimeo_id.'?api=1&wmode=transparent" frameborder="0"  webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';

    to:

    $vimeo_url = apply_filters( 'cycloneslider_slide_vimeo_url', 'http://player.vimeo.com/video/'.$vimeo_id.'?api=1&wmode=transparent' );
    
    $slides[$i]['vimeo_embed_code'] = '<iframe id="'.$slider_html_id.'-iframe-'.$i.'" width="'.$slider_settings['width'].'" height="'.$slider_settings['height'].'" src="'.$vimeo_url.'" frameborder="0"  webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';

    I’ll gladly send in a pull request to that effect, but couldn’t find the plugin on GitHub.

    Smile,
    Juliette

    https://wordpress.org/plugins/cyclone-slider-2/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author kosinix

    (@kosinix)

    You can use the cycloneslider_view_vars to do this. See http://docs.codefleet.net/cyclone-slider-2/filters/

    Wish I could, but it doesn’t look like the filter gets applied.

    Plugin Author kosinix

    (@kosinix)

    You must be running version 2.11.0+. Just got release yesterday

    Ah, ok, thanks. Will have a look at this next week and let you know how I get on.

    Hi @kosinix, ok, I’ve had some time to check out the changes and test it.
    I’ve got it working with about 8 times as much code as I had before…

    I think the plugin could do with some additional strategically placed filters, but for now, this will have to do.

    If you’d put the code up somewhere publicly (GitHub?), I’d gladly send in some pull requests with suggestions.

    Plugin Author kosinix

    (@kosinix)

    Hi Juliette,

    Thanks for taking the time to try this out and make it work.

    The reason I decided to create the cycloneslider_view_vars filter instead of a vimeo-specific filter because cycloneslider_view_vars is a more generic filter. That means you can filter all aspects of the slideshow not just the vimeo embed code.

    However, youre right. This results to much larger code if you want to filter just the vimeo embed code. I have a solution to offer in a form of a helper function.

    Add the filter code below. In this example I added this in my current theme’s functions.php:

    add_filter( 'cycloneslider_view_vars', 'myprefix_cycloneslider_view_vars' );
    function myprefix_cycloneslider_view_vars( $vars ){
    
    	$slides = isset($vars['slides']) ? $vars['slides'] : array();
    
    	foreach($slides as $index=>$slide){
    		$slides[$index]['vimeo_embed_code'] = filter_vimeo_embed_code( $slide );
    	}
    	$vars['slides'] = $slides;
    
    	return $vars;
    }

    Notice that inside it we call the filter_vimeo_embed_code function which is specific to the embed code only.

    The function, contains this code:

    function filter_vimeo_embed_code( $slide ){
    
    	$vimeo_url = 'http://player.vimeo.com/video/'.$slide['vimeo_id'].'?api=1&wmode=transparent'; // Do something here
    
    	return '<iframe id="cycloneslider-vimeo-test-1-iframe-0" width="960" height="600" src="'.$vimeo_url.'" frameborder="0"  webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
    
    }

    From now on you only have to worry about the code in filter_vimeo_embed_code function.

    Does that solve your problem? If not, please send me your code via kosinix@codefleet.net.

    PS. I dont maintain a github repo for CS2 at the moment as the plugin is already hosted at a svn in wordpress.org. It would be hard to maintain and sync two repo at the same time.

    Best regards

    Hi Kosinix, thanks for taking the time, however as I said, I already got it working.

    I’d created a similar helper function, but with some more defensive coding, your code would result in breakage.

    Also, I don’t agree with rebuilding the iframe, that goes against the principle of using a plugin. If you would change something in the plugin code, I would have to change it in my function as well, which is error prone and a maintenance nightmare.
    So the way I’ve implemented it, is to parse the src out of the original string, adjust it and then parse it back in again.

    If you like I’ll put my code up in a gist as an example for others (and yourself).

    Still, as I said before, it results in a lot more code than I had before and is also more error prone, so please do consider adding some additional filters.
    Having this filter does not exclude the possibility of having others.

    Smile,
    Juliette

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[Feature Request] Vimeo url filter’ is closed to new replies.