0

qTip2とUmbracoのインストールを使用しています。リッチテキストエディタに画像を挿入して、ロールオーバー時にフルサイズの画像を表示したい。

問題は、Umbracoのリッチテキストエディタがフルサイズよりも小さい画像を表示することです。リッチテキストエディタの幅に収まるようにします。したがって、フロントエンドに表示される画像には、たとえば「.jpg」の代わりに「_360x200.jpg」が追加されています

アンダースコアとそれ以降の終止符/ピリオドまでのすべてを置き換えるにはどうすればよいですか?

    // Create the tooltips only on document load
    $(document).ready(function() {
        $('.rightUnevenCol img').each(function() {
            // Grab fullsize image src
//Replace the underscore and everything after it before the '.' e.g. '_320x200.jpg' to '.jpg'
            var bigSrc = $(this).attr('src').replace(/_\d+$/, "");
            $(this).qtip({
                content: '<img src="' + bigSrc + '" alt="" />',
                // Set the height/width!!! This can cause positioning problems if not set
                position: {
                    target: 'mouse',
                    adjust: {
                        mouse: true
                    }
                },
                show: {
                    target: false,
                    event: 'mouseenter',
                    effect: true,
                    delay: 90,
                    solo: false,
                    ready: false,
                    modal: false
                },
                hide: {
                    target: false,
                    event: 'mouseleave',
                    effect: false,
                    delay: 0,
                    fixed: true,
                    when: {
                        event: 'unfocus'
                    },
                    inactive: false
                },
                style: {
                    tip: false,
                    classes: 'preview'
                },
                events: {
                    render: null,
                    move: null,
                    show: null,
                    hide: null,
                    toggle: null,
                    focus: null,
                    blur: null
                }
            });
        });

        // since the qTip copies the content of the info div, you can remove it now
        $('.rightUnevenCol img').remove('.preview');


    });​
4

1 に答える 1

1

試す

var bigSrc = $(this).attr('src').replace(/_[^\.]*/, "");

または、フォーマット123x456について確信がある場合

var bigSrc = $(this).attr('src').replace(/_\d{1,3}x\d{1,3}/, "");
于 2012-11-27T07:35:44.650 に答える