{"id":943,"date":"2012-08-15T01:21:52","date_gmt":"2012-08-15T01:21:52","guid":{"rendered":"http:\/\/www.dognmonkey.com\/techs\/?p=943"},"modified":"2012-08-15T01:21:52","modified_gmt":"2012-08-15T01:21:52","slug":"jquery-image-preview","status":"publish","type":"post","link":"https:\/\/www.dognmonkey.com\/mythemes\/jquery-image-preview.html","title":{"rendered":"Jquery Image Preview"},"content":{"rendered":"<blockquote>\n<p style=\"text-align: center;\"><em>2012-08-15 Since I don&#8217;t know how to resize the preview images, I had to implement the <a class=\"webpage\" title=\"James Padolsey Image Preview\" href=\"\/\/james.padolsey.com\/demos\/imgPreview\/full\/\" rel=\"\/idogjs\/ipreview\/imgpreviewdemos.jpg noopener noreferrer\" target=\"_blank\">James.Padolsey<\/a> ways to limit my image preview to width of 500px.<\/em><\/p>\n<p><code><br \/>\n<\/code><\/p>\n<p style=\"text-align: left;\">&lt;a class=&#8221;webpage&#8221; title=&#8221;James Padolsey Image Preview&#8221; href=&#8221;\/\/james.padolsey.com\/demos\/imgPreview\/full\/&#8221; rel=&#8221;\/idogjs\/ipreview\/imgPreviewDemos.jpg&#8221; target=&#8221;_blank&#8221;&gt;James.Padolsey&lt;\/a&gt; ways to limit my image preview to width of 500px.&lt;\/em&gt;&lt;\/p&gt;<\/p>\n<\/blockquote>\n<p style=\"text-align: center;\"><em>Need 3 links from the website and put them between &lt;head&gt;&lt;\/head&gt;<\/em><\/p>\n<blockquote>\n<p style=\"text-align: left;\"><em><\/em>&lt;!&#8211;iPreview&#8211;&gt;<\/p>\n<p style=\"text-align: left;\">&lt;link href=&#8221;\/imagepreview\/idogip.css&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text\/css&#8221; \/&gt;<\/p>\n<p style=\"text-align: left;\">&lt;script src=&#8221;\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.3.1\/jquery.min.js&#8221; type=&#8221;text\/javascript&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script src=&#8221;\/imagepreview\/imgpreview.full.jquery.js&#8221; type=&#8221;text\/javascript&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\nvar $iP=jQuery.noConflict();<br \/>\n$iP(document).ready(function(){<br \/>\n});<br \/>\n&lt;\/script&gt;<br \/>\n&lt;script src=&#8221;\/imagepreview\/idogip.js&#8221; type=&#8221;text\/javascript&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;!&#8211;End iPreview&#8211;&gt;<\/p>\n<\/blockquote>\n<p style=\"text-align: left;\">Custom JS:<\/p>\n<blockquote>\n<p style=\"text-align: left;\">idogip.css:<\/p>\n<p style=\"text-align: left;\">#imgPreviewWithStyles,<br \/>\n#imgPreviewWithStyles2,<br \/>\n#imgPreviewWithStyles3 {<br \/>\nbackground: #222 url(img\/loading.gif) no-repeat center;<br \/>\n-moz-border-radius: 10px;<br \/>\n-webkit-border-radius: 10px;<br \/>\npadding: 5px; \/*border thickness*\/<br \/>\nz-index: 999;<br \/>\nborder: none;<br \/>\n}<br \/>\n#imgPreviewWithStyles span,<br \/>\n#imgPreviewWithStyles2 span,<br \/>\n#imgPreviewWithStyles3 span {<br \/>\ncolor: white;<br \/>\nfont-size: 1em;<br \/>\ntext-align: center;<br \/>\ndisplay: block;<br \/>\npadding: 10px 0 3px 0;<br \/>\n}<\/p>\n<p style=\"text-align: left;\">idogip.js<\/p>\n<p style=\"text-align: left;\">$iP(&#8216;.preview&#8217;).imgPreview({<br \/>\ncontainerID: &#8216;imgPreviewWithStyles&#8217;,<br \/>\nimgCSS: { width: 500 },<br \/>\nonShow: function(link){<br \/>\n$iP(&#8216;&lt;span&gt;&#8217; + link.title + &#8216;&lt;\/span&gt;&#8217;).appendTo(this); \/\/\/*link.title shows title text on lower bar*\/<br \/>\n},<br \/>\n\/\/ When container hides:<br \/>\nonHide: function(link){<br \/>\n$iP(&#8216;span&#8217;, this).remove();<br \/>\n}<br \/>\n});<\/p>\n<p style=\"text-align: left;\">$iP(&#8216;.webpage&#8217;).imgPreview({<br \/>\ncontainerID: &#8216;imgPreviewWithStyles&#8217;,<br \/>\nsrcAttr: &#8216;rel&#8217;, \/\/\/* this one to display href that isn&#8217;t an image- put image here*\/<br \/>\nimgCSS: {<br \/>\n\/\/ Limit preview size:<br \/>\nwidth: 500<br \/>\n},<br \/>\n\/\/ When container is shown:<br \/>\nonShow: function(link){<br \/>\n$iP(&#8216;&lt;span&gt;&#8217; + link.href + &#8216;&lt;\/span&gt;&#8217;).appendTo(this);<br \/>\n},<br \/>\n\/\/ When container hides:<br \/>\nonHide: function(link){<br \/>\n$iP(&#8216;span&#8217;, this).remove();<br \/>\n}<br \/>\n});<br \/>\n});<\/p>\n<p>USAGE<br \/>\n<em>The code is simple just add the &#8220;class=&#8221;preview&#8221; or &#8220;webpage&#8221; whichever the case may be<\/em>&#8221;<\/p>\n<p style=\"text-align: center;\"><em>Use together with Mediabox Advanced <\/em><\/p>\n<blockquote><p>&lt;p style=&#8221;text-align: center;&#8221;&gt;&lt;a title=&#8221;imagepreview&#8221; href=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; rel=&#8221;lightbox&#8221;&gt;&lt;img style=&#8221;vertical-align: baseline; border: 3px solid black;&#8221; title=&#8221;My Alfa&#8221; src=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; alt=&#8221;My Alfa&#8221; width=&#8221;250&#8243; \/&gt;&lt;\/a&gt;&lt;\/p&gt;<\/p><\/blockquote>\n<p style=\"text-align: center;\"><a class=\"preview\" title=\"imagepreview\" href=\"\/media\/91alfaspider\/91alfa0.jpg\" rel=\"lightbox\"><img decoding=\"async\" style=\"vertical-align: baseline; border: 3px solid black;\" title=\"My Alfa\" src=\"\/media\/91alfaspider\/91alfa0.jpg\" alt=\"My Alfa\" width=\"250\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><!--nextpage--><\/p>\n<\/blockquote>\n<p><em><a title=\"jquery image preview\" href=\"\/\/cssglobe.com\/post\/1695\/easiest-tooltip-and-image-preview-using-jquery\" target=\"_blank\" rel=\"noopener noreferrer\">Easiest Tooltip and Image Preview<\/a> using Jquery for the website which is great for what I&#8217;m doing since most of my posts have many pictures. The great thing about this jquery is that it also work with any pop-ups that uses &#8220;rel&#8221; tag like Mediabox Advanced or PrettyPhoto or Shadowbox. I use the image preview with captions. Since it uses jquery and I use lots of them, therefore, I have to set jquery no conflict for this script also. Since I use Jquery for FancyBox already, all I need is the custom script for the &#8220;imagepreview&#8221; and add a &#8220;css&#8221; for the display. Quite simple and painless.<\/em><\/p>\n<p>&nbsp;<\/p>\n<blockquote><p><em>&lt;script src=&#8221;&lt;?php bloginfo(&#8216;template_url&#8217;); ?&gt;\/pops\/fancybox\/jquery.tools.min.js&#8221; type=&#8221;text\/javascript&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\nvar $iP=jQuery.noConflict();<br \/>\n$iP(document).ready(function(){<br \/>\n});<br \/>\n&lt;\/script&gt;<br \/>\n&lt;script src=&#8221;&lt;?php bloginfo(&#8216;template_url&#8217;); ?&gt;\/pops\/ipreview\/main.js&#8221; type=&#8221;text\/javascript&#8221;&gt;&lt;\/script&gt;<br \/>\n<\/em><\/p><\/blockquote>\n<p><em><br \/>\nThe main.js is the same as the author&#8217;s js file except all the &#8216;$&#8217; is changed to &#8216;$iP&#8217; for the no.conflict.<\/em><\/p>\n<blockquote>\n<pre id=\"line1\">this.imagePreview = function(){\n\t\/* CONFIG *\/\n\n\t\txOffset = 10;\n\t\tyOffset = 30;\n\n\t\t\/\/ these 2 variable determine popup's distance from the cursor\n\t\t\/\/ you might want to adjust to get the right result\n\n\t\/* END CONFIG *\/\n\t$iP(\"a.preview\").hover(function(e){\n\t\tthis.t = this.title;\n\t\tthis.title = \"\";\n\t\tvar c = (this.t != \"\") ? \"&lt;br\/&gt;\" + this.t : \"\";\n\t\t$iP(\"body\").append(\"&lt;p id='preview'&gt;&lt;img src='\"+ this.href +\"' alt='Image preview' \/&gt;\"+ c +\"&lt;\/p&gt;\");\n\t\t$iP(\"#preview\")\n\t\t\t.css(\"top\",(e.pageY - xOffset) + \"px\")\n\t\t\t.css(\"left\",(e.pageX + yOffset) + \"px\")\n\t\t\t.fadeIn(\"fast\");\n    },\n\tfunction(){\n\t\tthis.title = this.t;\n\t\t$iP(\"#preview\").remove();\n    });\n\t$iP(\"a.preview\").mousemove(function(e){\n\t\t$iP(\"#preview\")\n\t\t\t.css(\"top\",(e.pageY - xOffset) + \"px\")\n\t\t\t.css(\"left\",(e.pageX + yOffset) + \"px\");\n\t});\n};\n\n\/\/ starting the script on page load\n$iP(document).ready(function(){\n\timagePreview();\n});<\/pre>\n<\/blockquote>\n<p><em>The css is the same as the author&#8217;s css except some colors changed for my dark theme website.<\/em><\/p>\n<blockquote>\n<p id=\"line1\">#preview{<\/p>\n<p>position:absolute;<\/p>\n<p>border:1px solid #F75D59;<\/p>\n<p>background:#150517;<\/p>\n<p>padding:10px 10px;<\/p>\n<p>display:none;<\/p>\n<p>font-weight:500;<\/p>\n<p>font-style: italic;<\/p>\n<p>font-size: 16px;<\/p>\n<p>color:#F75D59;<\/p>\n<p>border-radius: 7px;<\/p>\n<p>-moz-border-radius: 7px;<\/p>\n<p>-moz-box-shadow: 1px 1px 1px 1px #F75D59;<\/p>\n<p>box-shadow: 1px 1px 1px 1px #F75D59;<\/p>\n<p>}<\/p><\/blockquote>\n<p><em>The code is simple just add the &#8220;class=&#8221;preview&#8221;<\/em>&#8221;<\/p>\n<p style=\"text-align: center;\"><em>Use together with Mediabox Advanced <\/em><\/p>\n<blockquote><p>&lt;p style=&#8221;text-align: center;&#8221;&gt;&lt;a title=&#8221;imagepreview&#8221; href=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; rel=&#8221;lightbox&#8221;&gt;&lt;img style=&#8221;vertical-align: baseline; border: 3px solid black;&#8221; title=&#8221;My Alfa&#8221; src=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; alt=&#8221;My Alfa&#8221; width=&#8221;250&#8243; \/&gt;&lt;\/a&gt;&lt;\/p&gt;<\/p><\/blockquote>\n<p style=\"text-align: center;\"><a class=\"preview\" title=\"imagepreview\" href=\"\/media\/91alfaspider\/91alfa0.jpg\" rel=\"lightbox\"><img decoding=\"async\" style=\"vertical-align: baseline; border: 3px solid black;\" title=\"My Alfa\" src=\"\/media\/91alfaspider\/91alfa0.jpg\" alt=\"My Alfa\" width=\"250\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><em>Use together with PrettyPhoto<\/em><\/p>\n<blockquote><p>&lt;p style=&#8221;text-align: center;&#8221;&gt;&lt;a title=&#8221;imagepreview&#8221; href=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; rel=&#8221;prettyPhoto&#8221;&gt;&lt;img style=&#8221;vertical-align: baseline; border: 3px solid black;&#8221; title=&#8221;My Alfa&#8221; src=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; alt=&#8221;My Alfa&#8221; width=&#8221;250&#8243; \/&gt;&lt;\/a&gt;&lt;\/p&gt;<\/p><\/blockquote>\n<p style=\"text-align: center;\"><a class=\"preview\" title=\"imagepreview\" href=\"\/media\/91alfaspider\/91alfa0.jpg\" rel=\"prettyPhoto\"><img decoding=\"async\" style=\"vertical-align: baseline; border: 3px solid black;\" title=\"My Alfa\" src=\"\/media\/91alfaspider\/91alfa0.jpg\" alt=\"My Alfa\" width=\"250\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><em>Use together with Shadowbox<\/em><\/p>\n<blockquote><p>&lt;p style=&#8221;text-align: center;&#8221;&gt;&lt;a title=&#8221;imagepreview&#8221; href=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; rel=&#8221;shadowbox&#8221;&gt;&lt;img style=&#8221;vertical-align: baseline; border: 3px solid black;&#8221; title=&#8221;My Alfa&#8221; src=&#8221;\/media\/91alfaspider\/91alfa0.jpg&#8221; alt=&#8221;My Alfa&#8221; width=&#8221;250&#8243; \/&gt;&lt;\/a&gt;&lt;\/p&gt;<\/p><\/blockquote>\n<p style=\"text-align: center;\"><a class=\"preview\" title=\"imagepreview\" href=\"\/media\/91alfaspider\/91alfa0.jpg\" rel=\"shadowbox\"><img decoding=\"async\" style=\"vertical-align: baseline; border: 3px solid black;\" title=\"My Alfa\" src=\"\/media\/91alfaspider\/91alfa0.jpg\" alt=\"My Alfa\" width=\"250\" \/><\/a><\/p>\n<p><em><br \/>\n<\/em><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2012-08-15 Since I don&#8217;t know how to resize the preview images, I had to implement the James.Padolsey ways to limit my image preview to width of 500px. &lt;a class=&#8221;webpage&#8221; title=&#8221;James Padolsey Image Preview&#8221; href=&#8221;\/\/james.padolsey.com\/demos\/imgPreview\/full\/&#8221; rel=&#8221;\/idogjs\/ipreview\/imgPreviewDemos.jpg&#8221; target=&#8221;_blank&#8221;&gt;James.Padolsey&lt;\/a&gt; ways to limit my image preview to width of 500px.&lt;\/em&gt;&lt;\/p&gt; Need 3 links from the website and put them <a href=\"https:\/\/www.dognmonkey.com\/mythemes\/jquery-image-preview.html\" class=\"more-link\">&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[670],"class_list":["post-943","post","type-post","status-publish","format-standard","hentry","category-pop-ups","tag-jquery-image-preview"],"views":3,"_links":{"self":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/posts\/943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/comments?post=943"}],"version-history":[{"count":0,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/posts\/943\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/media?parent=943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/categories?post=943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/tags?post=943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}