-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Reimplement the Zooming Image Tool #36012
feat: Reimplement the Zooming Image Tool #36012
Conversation
0efa093
to
7586e11
Compare
7586e11
to
b2aa1fe
Compare
b2aa1fe
to
1e28d78
Compare
Sandbox deployment successful 🚀 |
1e28d78
to
ec1e23b
Compare
<div class="zooming-image-container" style="position: relative;"> | ||
<a class="zooming-image" data-src=""> | ||
<!-- The following sample image is in the public domain. Source: https://commons.wikimedia.org/wiki/File:12-Color-SVG.svg --> | ||
<img alt="A color wheel." src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiCiB3aWR0aD0iMTMwMCIgaGVpZ2h0PSIxMzAwIiB2aWV3Qm94PSItNjUwIC02NTAgMTMwMCAxMzAwIj4KIDxkZWZzPgogPHBhdGggaWQ9ImsiIHN0cm9rZT0iYmx1ZSIgc3Ryb2tlLXdpZHRoPSIzIgogZD0iTTAsMCBoMjAwIGEyMDAsMjAwIDAgMSwwIC00MCwtMTUwIHoiIC8+CgogPGZpbHRlciBpZD0icyIgZmlsdGVyVW5pdHM9Im9iamVjdEJvdW5kaW5nQm94IgogICAgICAgICAgeD0iLTAuMjUiIHk9Ii0wLjI1IiB3aWR0aD0iMS41IiBoZWlnaHQ9IjEuNSI+CiAgICA8ZmVDb2xvck1hdHJpeCB0eXBlPSJzYXR1cmF0ZSIgdmFsdWVzPSIwLjMzIiBpbj0iU291cmNlR3JhcGhpYyIgLz4KIDwvZmlsdGVyPgogIDx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jc2NoaXJtIiAvPgogPHVzZSB0cmFuc2Zvcm09InNjYWxlKDAuMDY4NykiIGZpbHRlcj0idXJsKCNzNjg3KSIgeGxpbms6aHJlZj0iI3NjaGlybSIgLz4KIDx1c2UgdHJhbnNmb3JtPSJzY2FsZSgwLjA1NSkiIGZpbHRlcj0idXJsKCNzNTUpIiB4bGluazpocmVmPSIjc2NoaXJtIiAvPgogPHVzZSB0cmFuc2Zvcm09InNjYWxlKDAuMDQ0KSIgZmlsdGVyPSJ1cmwoI3M0NCkiIHhsaW5rOmhyZWY9IiNzY2hpcm0iIC8+CiA8dXNlIHRyYW5zZm9ybT0ic2NhbGUoMC4wMzUpIiBmaWx0ZXI9InVybCgjczM1KSIgeGxpbms6aHJlZj0iI3NjaGlybSIgLz4KIDx1c2UgdHJhbnNmb3JtPSJzY2FsZSgwLjAyOCkiIGZpbHRlcj0idXJsKCNzMCkiIHhsaW5rOmhyZWY9IiNzY2hpcm0iIC8+CiA8L2c+Cjwvc3ZnPg==" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewer:
I tried using a placeholder image that already exists in the codebase, but there are issues when linking to local assets outside a course via bare /static/
URLs (see openedx/frontend-app-authoring#1265 (comment)).
This is the least egregious alternative to linking to some random image on the internet that I found: a base64 encode of an SVG with a small footprint (~5kb) that is still complex enough to illustrate the purpose of the tool.
Sandbox deployment successful 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense to me.
What's the authoring flow for existing (broken) Zoom Images? Do they just create a new block with the template, and delete the old, broken block? |
ec1e23b
to
260800a
Compare
This recreates the Zooming Image Tool template for the HTML block. It does it in such a way that doesn't depend on any external resources: both the loupe code and sample image are inlined. Some benefits to this version are: * We can now maintain the loupe javascript code properly * Because the javascript is included in the contents of the block itself, the course author can customize it as needed * As opposed to the previous iteration, the magnified image URL is now optional: if it's not present, the regular image will be used for magnification * There can now be two or more instances of the tool in the same unit. This also removes some CSS left over from the previous iteration.
260800a
to
29e81d2
Compare
@pdpinch, if a text block that was created with the previous version of the Zooming Tool is currently working (which I'm told is the case at edx.org and at MIT), nothing needs to be done. If a pre-existing text block is not working, then the easiest way will indeed be to recreate it with the new version of the tool after this patch merges. It would be difficult to automate this, given the nature of the thing: it's just HTML in the middle of other, arbitrary HTML. It is one of the downsides of the tool not being an XBlock: because the content is unstructured, there's no easy way to automatically account for existing content. |
Sandbox deployment successful 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working as expected! Thank you :)
Seems like this is just a bug fix then and we needn't mention it in the release notes -- assuming it's merged by the time the release and release notes actually go out. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
Description
This recreates the Zooming Image Tool template for the HTML block. It does it in such a way that doesn't depend on any external resources: both the loupe code and sample image are inlined.
Some benefits to this version are:
We can now maintain the loupe javascript code properly
Because the javascript is included in the contents of the block itself, the course author can customize it as needed
As opposed to the previous iteration, the magnified image URL is now optional: if it's not present, the regular image will be used for magnification
There can now be two or more instances of the tool in the same unit.
This also removes some CSS left over from the previous iteration.
Testing
This can be tested in the sandbox:
🎓 LMS
📝 Studio
Just insert a new Text component in Studio and select the last option, "Zooming Image Tool". The instructions in the generated HTML should be self-explanatory.
Screenshot