Deprecated: Optional parameter $post_id declared before required parameter $field is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php on line 54

Deprecated: Optional parameter $value declared before required parameter $field is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php on line 166

Deprecated: Optional parameter $post_id declared before required parameter $field is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php on line 166

Deprecated: Optional parameter $key declared before required parameter $value is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/ajax/class-acf-ajax.php on line 76

Notice: Function wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the codepen-embed-script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/jwblogger/jwBlogger/wp-includes/functions.php on line 6114

Deprecated: Optional parameter $i declared before required parameter $post_id is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-repeater.php on line 720

Deprecated: Optional parameter $i declared before required parameter $post_id is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-repeater.php on line 786

Deprecated: Optional parameter $name declared before required parameter $field is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php on line 1038

Deprecated: Optional parameter $i declared before required parameter $post_id is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php on line 1074

Deprecated: Optional parameter $i declared before required parameter $post_id is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php on line 1126

Deprecated: Optional parameter $id declared before required parameter $field is implicitly treated as a required parameter in /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-gallery.php on line 296

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/jwblogger/jwBlogger/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php:54) in /home/jwblogger/jwBlogger/wp-includes/rest-api/class-wp-rest-server.php on line 1893
{"id":338,"date":"2018-02-06T11:36:38","date_gmt":"2018-02-06T18:36:38","guid":{"rendered":"http:\/\/blog.jeffwilkerson.net\/?p=338"},"modified":"2018-02-06T11:36:38","modified_gmt":"2018-02-06T18:36:38","slug":"extending-magnific-popup-jquery-plugin-for-scrollable-images","status":"publish","type":"post","link":"https:\/\/blog.jeffwilkerson.net\/2018\/02\/06\/extending-magnific-popup-jquery-plugin-for-scrollable-images\/","title":{"rendered":"Extending Magnific Popup jQuery Plugin for scrollable images"},"content":{"rendered":"

This module leverages the jQuery pluging Magnify<\/a> to display galleries of long images by making the image container vertically scroll. <\/p>\n

Original Problem<\/h3>\n

I wanted to display screenshots of recent website projects that the user could easily navigate. I figured a modal window would be the best tool to display these screenshots. <\/p>\n

I really like the Magnify jQuery plugin because I can easly scroll through the images by clicking on the image itself, or easily dismiss the modal window by clicking anywhere outside the image. (As someone who has mobility challenges, large clickable areas that trigger my desired actions, rather than specific tiny icons, are very appealing.) But, in my case, I am trying to display long images ( > 2,000px high), and when displaying these images in the Magnigic popup, the image would be squished to the height of the window. <\/p>\n

I wanted to find a way to vertically scroll these images from inside the Magnific Popup modal window.<\/p>\n

Solution<\/h3>\n

I produced a modal window that maximizes the width of an image and allows vertical scrolling. Starting with Magnific Popup v1.1.0, I acheived my UI goals with a few extra styles and initializing the widget with a afew custom configuration options.<\/p>\n

First, here is the Twig template used to trigger the modal window. This snippet represents one gallery of images, and here is an example data object<\/a> which would be used by this template<\/p>\n

\n\t
\n\t\t{% for screenshot in page.screenshots %}\n\t\t\t{% set thumbnail = page.media[screenshot.thumbnail] %} \n\t\t\t{% set caption = screenshot.caption|markdown %}\n\t\t\t{% set full = page.media[screenshot.full] %}\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t<\/a>\n\t\t\t<\/div>\n\t\t{% endfor %}\n\t<\/div>\n<\/div><\/pre>\n<\/p>\n

Next, here is how I am initializing the popup\/modal. The type of the popup widget will be image, and I am customizing the HTML template by wrapping the image in a div.scrolling-viewport<\/code> container.<\/p>\n

$(function() {\n\tconsole.log('go to bed');\n\t$('.project-thumbnail').magnificPopup({\n\t\ttype: 'image',\n\t\tmainClass: 'scrolling-image',\n\t\timage: {\n\t\t\tmarkup: '
'+\n\t\t\t\t\t'
<\/div><\/div>'+\n\t\t\t\t\t'
' +\n\t\t\t\t\t\t'
<\/div><\/div>'+\n\t\t\t\t\t'<\/div>' +\n\t\t\t\t\t'
'+\n\t\t\t\t\t'
<\/div>'+\n\t\t\t\t\t'
<\/div>'+\n\t\t\t\t'<\/div>'+\n\t\t\t'<\/div>', \/\/ Popup HTML markup. `.mfp-img` div will be replaced with img tag, `.mfp-close` by close button\n\n\t\t\tverticalFit: false,\n\t\t\ttitleSrc: function(item) {\n\t\t\t\treturn item.el.attr('data-caption');\n\t\t\t}\n\t\t},\n\t\tgallery: {\n\t\t\tenabled: true\n\t\t}\n\t\t\n\t});\n\n});<\/pre>\n<\/p>\n

Finally, I throw on some custom styles (SASS). Most notably, I give a max-width to an outer content container (.mfp-conten<\/code>`) and make the .mpf-figure<\/code> container a flexbox column. The footer (.mfp-bottom-bar<\/code>) is set to not flex (flex: 0<\/code>). The last step is to put a max-height<\/code> and an overflow-y: scroll<\/code> style on our .scrolling-viewport<\/code> container.<\/p>\n

.mfp-bg {\n\tz-index: 5000;\n}\n.mfp-wrap.scrolling-image {\n\tz-index: 5001;\n\t.mfp-content {\n\t\tmax-width: 90%;\n\t\tmargin: 0 auto;\n\t\t\n\t}\n\t.mfp-close {\n\t\tposition: relative;\n\t\tright: 0;\n\t\theight: auto;\n\t\tline-height: 1;\n\t\tfont-size: 40px;\n\t}\n\t.mfp-figure {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\t&:after {\n\t\t\tbackground-color: transparent !important;\n\t\t}\n\t}\n\t.scrolling-viewport {\n\t\tmax-height: 75vh;\n\t\toverflow-y: scroll;\n\t\txmargin: 40px 0;\n\t\timg {\n\t\t\tpadding: 0;\n\t\t}\n\t}\n\t.mfp-bottom-bar {\n\t\tposition: relative;\n\t\tbackground: #FFF;\n\t\tpadding: 15px;\n\t\tdisplay: flex;\n\t\tmargin-top: 0;\n\t\t.mfp-title, .mfp-counter {\n\t\t\tline-height: 1;\n\t\t\tcolor: $navy;\n\t\t}\n\t\t.mfp-title {\n\t\t\tpadding-right: 15px;\n\t\t\tflex: 1;\n\t\t}\n\t\t.mfp-counter {\n\t\t\tfont-size: 80%;\n\t\t\tposition: relative;\n\t\t\tflex: 0;\n\t\t}\n\t}\n}<\/pre>\n<\/p>\n

Results<\/h3>\n

Look here for a working example of the solution<\/a>.<\/p>\n

View full source code<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

This module leverages the jQuery pluging Magnify to display galleries of long images by making the image container vertically scroll. Original Problem I wanted to display screenshots of recent website projects that the user could easily navigate. I figured a modal window would be the best tool to display these screenshots. I really like the […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-338","post","type-post","status-publish","format-standard","hentry","category-development"],"_links":{"self":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/posts\/338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/comments?post=338"}],"version-history":[{"count":0,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/posts\/338\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/media?parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/categories?post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jeffwilkerson.net\/wp-json\/wp\/v2\/tags?post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}