Skip to content

Commit 4a6c756

Browse files
committed
feat: image embed feature added
1 parent 24686b4 commit 4a6c756

3 files changed

Lines changed: 25 additions & 17 deletions

File tree

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h1>emoticons-js</h1>
2525
<div id="element">
2626
<div>http://www.w3schools.com/html/mov_bbb.mp4 https://i.imgur.com/yBVxILF.jpg www.ng-conf.org https://www.iitr.ac.in ROTFL!!!! Now this explains :P why Kejriwal & his fans are upset with Yogendra Yadav. Because he had praised Narendra :smile: Modi and Gujarat model in an interview.Check this 1-min clip in which Yogendra Yadav openly praises Modis Gujarat development https://vimeo.com/119199079"</div>
2727
<div>fdf gkjfd jedfkdsf https://www.youtube.com/watch?v=bQRLVxZHKPs :p :D</div>
28-
<div>kjkTorquis, index, https://www.cca.edu/sites/default/files/pdf/08/word-to-pdf.pdf http://www.w3schools.com/html/horse.mp3 et luna.Pol,
28+
<div>kjkTorquis, http://www.iitr.ac.in/Main/assets/images/topold.jpg index, https://www.cca.edu/sites/default/files/pdf/08/word-to-pdf.pdf http://www.w3schools.com/html/horse.mp3 et luna.Pol,
2929
```
3030
#include <iostream>
3131

src/jquery.emoticons.css

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,11 @@ code.has-numbering {
249249
width : 100%;
250250
border-radius : 2px;
251251
border : 1px solid #e4e4e4;
252-
min-height : 250px;
253-
max-height : 250px;
254252
overflow : hidden;
255253
cursor : pointer;
256-
padding-bottom : 5px;
257-
-webkit-transition : all 0.5s linear;
258-
-o-transition : all 0.5s linear;
259-
-moz-transition : all 0.5s linear;
260-
-ms-transition : all 0.5s linear;
261-
-kthtml-transition : all 0.5s linear;
262-
transition : all 0.5s linear;
263254
box-shadow : 0px 1px 1px 0 rgba(0, 0, 0, 0.26);
264-
border-bottom : 5px solid #ffffff;
265255
margin : 10px 0;
266-
}
267-
268-
.ejs-image-long {
269-
max-height : 800px;
256+
padding : 5px;
270257
}
271258

272259
.ejs-image img, .ejs-image-long img {

src/jquery.emoticons.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
link : true,
321321
linkTarget : '_self',
322322
pdfEmbed : true,
323+
imageEmbed :true,
323324
audioEmbed : false,
324325
videoEmbed : true,
325326
basicVideoEmbed: true,
@@ -487,7 +488,6 @@
487488
});
488489
},
489490
embed: function (data, opts) {
490-
console.log(data);
491491
var ytRegex = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[?=&+%\w-]*/gi;
492492
var vimeoRegex = /https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)*/gi;
493493
var videoDimensions = this.dimensions(opts);
@@ -633,7 +633,6 @@
633633
return '<pre><code class="ejs-code ' + m2 + '">' + c + '</code></pre>';
634634
}
635635
);
636-
console.log(text);
637636
return text;
638637
}
639638

@@ -653,6 +652,27 @@
653652
}
654653
};
655654

655+
var imageProcess = {
656+
template: function (url) {
657+
var t = '<div class="ejs-image">' +
658+
' <div class="ne-image-wrapper">' +
659+
' <img src="' + url + '"/>' +
660+
' </div>' +
661+
'</div>';
662+
663+
return t;
664+
665+
},
666+
embed : function (str) {
667+
var i = /((?:https?):\/\/\S*\.(?:gif|jpg|jpeg|tiff|png|svg|webp))/gi;
668+
if (str.match(i)) {
669+
var template = this.template(RegExp.$1);
670+
str=str+template;
671+
}
672+
return str;
673+
}
674+
}
675+
656676
function _driver(elem) {
657677
elem.each(function () {
658678
var input = $(this).html();
@@ -671,6 +691,7 @@
671691
input = (defaultOptions.audioEmbed) ? audioProcess.embed(input) : input;
672692
input = (defaultOptions.highlightCode) ? codeProcess.highlight(input) : input;
673693
input = (defaultOptions.basicVideoEmbed) ? videoProcess.embedBasic(input) : input;
694+
input = (defaultOptions.imageEmbed) ? imageProcess.embed(input) : input;
674695
$(that).html(input);
675696
if (defaultOptions.videoEmbed) {
676697
$.when(videoProcess.embed(input, defaultOptions)).then(

0 commit comments

Comments
 (0)