I just landed on trunk a fix for the annoying centering of all images. This was some code which we inherited in the fork, and which is likely deprecated with the newer versions of TCPDF.
The featured image setting is still observed from the admin panel, and the featured image will still be horizontally centered below the title and above the content. All other images should be aligned as displayed (and subject to the scaling factor as set in the admin panel; this fix only addresses the centering issue).
This latest trunk build also incorporates the two new shortcodes for manual icon placement and PDF page breaks (see the readme for details).
All that is necessary to update an existing installation is to pull wp-post-to-pdf-enhanced.php, wpptopdfenh_shortcodes.php, and readme.txt from /trunk in the svn repository and overlay the existing ones in your local plugin directory.
Feedback is welcome. Barring any issues with what I’ve added/fixed, this will likely be tagged version 1.0.1 (custom css support is looking more like 1.0.2).
Cheers, and Happy New Year!
sudo svn up At revision 833330
Featured image does not centre align now (as you described) (link).
not sure if the other images in the page content are aligning correctly for me though?
centre alignment on images works
right alignment on images doesn’t seem to work
shortcodes works (both page break and icon placement)
not sure if you can replicate?
The first heading (<h1>) of the page content falls on top of the featured image for some reason. This doesn’t happen with other images that precede h1’s in the page content so it might be particular to the featured image.
Also with the image scaling option found via the plugin admin interface does 0.5 mean half size and 2 mean double size?
thanks again for the work!
I do see this on your site. I think I know why the original code was there in the first place, and I think I may know how to tweak it to fix the positioning for the featured image alone.
What’s more of a mystery to me is why the text flow isn’t happening on the one page and why the right-alignment isn’t working (these worked in my tests). Perhaps it’s a matter of image size and scaling factor, though, as these could definitely change at least the flow of the text around the images.
I’ll investigate further and advise of the next drop!
Re: scaling factor – Yes, 0.5 = 1/2 size and 2 = double size. It’s just a straight multiplier.
Scaling factor: For some reason, this seems to be working backwards from the way I originally implemented it, where it is a factor of reduction rather than enlargement. I’ll need to look at it again.
Meanwhile, Alex, I’ve updated the main php file again; please pull from trunk when you have a moment, and test on your site. What template are you using? I can’t seem to get a featured image to size the way yours is displayed (I grabbed your images, too).
Also, you might want to look at my test page for comparison. Images are aligning for me; no issues with right alignment; and no overlap with the featured image.
Let me know what you see, please.
Thanks so much for testing and providing such great feedback!
I’ve just stuck with one big test page for now.
php5, php5-gd (should I install any others for the plugin?)
I still have problems with image alignment at the moment. When I look at the pdf from your test page it too seems to have the same image alignment problems I think? (I tried foxit pdf reader on windows and document viewer on ubuntu). Perhaps something’s changed since you last looked it?
Here’s a screenshot in case we’re seeing different things
It doesn’t seem to be theme dependent (tried changing to twentyfourteen theme, reset cache and redownload pdf)
PS: should I use the github for this type of thing instead?
shortcodes working (page break, download icon)
text alignment working
featured images working
imaging scaling seems to be reversed I think?
i.e. a larger number number results in smaller images
this is the nginx error site specific log generated from one click of the download pdf icon in case it helps
Image scaling is actually a ratio, Alex, so consider that what you end up with is 1. Thus, a ratio of 1.25 is 1.25:1 (or 5:4), so your end result will be 20% smaller than original. I did not recall this tidbit when last I spoke off the top of my head (oops!).
In my pdf from your test page, the images were too big to get the alignment, as they essentially filled the entire text area, each on a different sheet (perhaps you were adjusting when I ran the pdf).
github: While I have an account on github, I don’t use it for my own stuff. I should set you up with a login to my Mantis bug tracker, I think. I’ll see to that this evening.
Meanwhile, to better test image alignment, try flipping your scaling ratio around (I should clarify the language in the admin section or work out the math to make it more logical – I took that straight from TCPDF) and get the images small enough to test. Also – very important – image alignment should be tied to the image info and not the paragraph alignment. On my test page, for example, I used the [loremimage] shortcode, and aligned that right, but did not get the desired result, as the alignment available to me was text alignment and not image alignment.
Thanks! I’ll follow up later on this evening!
Thanks for the log snippet, too! I’m testing on Apache with PHP 5.3.19 and not seeing this (even when I specifically crank up verbosity). I’ll comb through what you’ve posted.
ah ok I understand now thanks! (I missed your reply about image scaling before)
cool ok I’ve turned the image scaling back down to 1.25.
I specify the image alignment via the “add media” page (which adds classes to the img element (see here for the page code)? (i.e. not using <p style=”text-align: center;”>?)
Hmmm… Looks like I need to have another go at the div tag wrapping, perhaps. Thanks for the code for the pages; that helps, as I’m not able to duplicate the issue just yet. Perhaps I should have a go under PHP 5.4, as I’m running 5.3 on my production box.
I’ve pushed some minor changes to trunk to clean up some of the notices we’re seeing in the log (I turned up verbosity again, and was able to generate the same issues under OS/2 / Apache). There are still some nagging issues with sloppy code (of mine, mostly, not Neerav’s original work), and an interesting twist of fate WRT the undefined constant “ENT_HTML401” which was added in PHP 5.4, but not present under 5.3 (want to make things as backward compatible as possible). I’ll work on getting those ironed out.
I also haven’t gooten you set up in my bug tracker yet, but I’ll put that back on the list for this evening, Alex.
Thanks again for all of your help and feedback!
Still wrestling with this one, Alex. I’ve gotten a bit closer (grab the latest trunk build when you get a chance).
The real problem is that TCPDF doe snot seem to want to respect CSS alignment properties (even inline) for images. There is a function which specifically clears a space for an image so that text is not rendered there, but it’s really difficult to make those calculations on the fly (though that’s where this is ultimately headed, if Nicola doesn’t change the manner in which TCPDF handles images).
Anyway, more new stuff in the admin UI, and be aware that the default paper size is now US Letter (apologies – to all – from this side of the Pond). Default unit of measurement remains mm, however.
- The topic ‘Image positioning fix’ is closed to new replies.