3

I was wondering if some could help me to produce another case in Fancybox 2 media helper for Soundcloud. I need it to load the soundclooud iframe when the fancybox is triggered - otherwise with a number of embeds things go really slow.

I'm not very familiar with regular expressions - hence my enquiry.

The google part looks like this:

google_maps : {
    matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i,
    type : 'iframe',
    url  : function( rez ) {
        return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed');
    }
}

Now if we take the standard iframe code for soundcloud:

<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F91535490"></iframe>

I believe we would take the url from the iframe as the direct link does not contain the id of the track - only string representation of it.

What I've got so far (trying hard ;) - is the following, which doesn't work:

soundcloud : {
        matcher : /w\.soundcloud\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|url\?)(.*)/i,
        type : 'iframe',
        url  : function( rez ) {
            return '//w.soundcloud.com/player/?url=$1';
        }
}

Could someone point me in the right direction here please?

4

1 に答える 1

2

わかりました-不思議に思っている人のために-私はそれを次のように動作させることができました:

 soundcloud : {
        matcher : /w\.soundcloud\.com\/player\/(.*)\/?(.*)/,
        type : 'iframe',
        url  : function( rez, params, obj ) {
            obj.width = '600px';
            obj.height = '166px';
            return '//w.soundcloud.com/player/' + rez[1];
        }
}
于 2013-06-26T09:52:17.957 に答える