2012-11-27 76 views
0

我正在使用qTip2和我的Umbraco安裝。我希望將我的圖像插入到我的富文本編輯器中,以便在翻轉時顯示全尺寸圖像。qTip2翻轉縮略圖顯示全尺寸圖像

問題是,Umbraco的富文本編輯器顯示的圖像小於全尺寸。適合富文本編輯器的寬度。因此前端顯示的圖像具有例如'_360x200.jpg'加入而不是'.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'); 


    });​ 

回答

1

嘗試

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

或者,如果你確定格式123x456

var bigSrc = $(this).attr('src').replace(/_\d{1,3}x\d{1,3}/, ""); 
+0

感謝@Yury Tarabanko我使用的第一選擇,因爲我的格式將發生變化。 – JV10

相關問題