Problem/Motivation
If inline images are resized in CKeditor, the image will not enlarge in photoswipe since data-pswp-width and data-pswp-height are populated with the height and width of the displayed image from the dom, not the natural height and width of the image
Steps to reproduce
Insert an inline image and resize it
Proposed resolution
There needs to be a way to pick up the intrinsic, natural dimensions of the image to populate the data-pswp-width/height values. The current $dom = Html::load($text); doesn't do the trick because it can't know the actual dimensions of the image. The URLs of the images need to be parsed out and the intrinsic size determined from the file
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork photoswipe_inline-3500993
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
atratus commentedThis works for me, but it is problematic since it assumes
allow_url_fopenis on for images that aren't in the local filesystem, and I took out the test for an existing class attribute on the image. I'm not sure why that was there, but I assume you had a reason. I'm posting this not as a solution, but as an idea toward a solution.Comment #3
ivnishLooks like a project-specific issue. I think you need to disable this contrib module and use own text filter in custom code
Comment #4
atratus commentedNo, I think you are missing the point of the problem. If an inline image is resized in the WYSIWYG editor, your code as it is picks up the height and width of the resized image from the html img attributes, not the intrinsic size of the image, so clicking on the image just brings up the same small version of the image in Photoswipe instead of the full-sized image, which is the point of using Photoswipe. What I have given you fixes that for both locally and remotely hosted images.
Consider this scenario: say I insert an inline image in a post that's 4000px x 3000px intrinsically, and I scale it down in the WYSIWYG editor so it is 200 x 150. A user clicks on the image expecting a larger version, but with your code all they get is the same 200 x 150 pixel scaled image, whereas with what I have done the image fills the window as expected and they can further zoom to the intrinsic size.
Comment #5
ivnishThanks, now I can confirm it
Comment #6
bramdriesenI also bumped into this problem. The problem is that the data-pswp-width and data-pswp-height are being calculated from the image in the ckeditor, but not the source image.
This needs an issue fork,
Comment #7
bramdriesenComment #8
bramdriesenComment #9
bramdriesenComment #11
bramdriesenUpdated logic, cleaned up the variable names to be in line with best practices, added a simple test which checks the image size.
Comment #12
bramdriesenComment #14
ivnishThanks!