stianlik
Forum Replies Created
-
Forum: Plugins
In reply to: [Polylang] PHP notices on plugin activationHi,
This is not directly related, but I’m getting warnings on public pages with WordPress in DEBUG mode using PHP 5.4:
Notice: Undefined property: PLL_Language::$page_on_front in /vagrant/www/wp-content/plugins/polylang/frontend/frontend-static-pages.php
The problem can be fixed by declaring the missing properties:
class PLL_Language { public $page_on_front, $page_for_posts; }
Forum: Plugins
In reply to: [PDF Thumbnails] HTTP ErrorSetIteratorIndex requires imagick 6.2.9 or newer, can you check the version number in phpinfo?
Thank you for posting the actual error, makes debugging much easier ??
Forum: Plugins
In reply to: [PDF Thumbnails] how to set size of thumbnail imageSeems like
scaleImage
does not support auto-calculating height values with$bestfit
defined. You can use the following sample to size your image exactly770x450
.add_action('pdf_thumbnails_generate_image_blob', function ($blob, $filename) { $imagick = new Imagick($filename); $imagick->setIteratorIndex(0); $imagick->setImageFormat('jpg'); $imagick->thumbnailImage(770, 450, true, true); return $imagick->getImageBlob(); }, 10, 2);
If you only want to limit the width to
770
, you can use the following sample:add_action('pdf_thumbnails_generate_image_blob', function ($blob, $filename) { $imagick = new Imagick($filename); $imagick->setIteratorIndex(0); $imagick->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE); $imagick->setImageFormat('jpg'); $imagick->resizeImage(770, 0, Imagick::FILTER_POINT, 1); return $imagick->getImageBlob(); }, 10, 2);
If you would like to learn more about Imagick, there is a tutorial on SitePoint.
Forum: Plugins
In reply to: [PDF Thumbnails] how to set size of thumbnail imageI recommend that you use the thumbnail built into WordPress to define image sizes, but it is also possible to do it manually using scaleImage. The following should limit your image width to 770px:
add_action('pdf_thumbnails_generate_image_blob', function ($blob, $filename) { $imagick = new Imagick($filename); $imagick->setIteratorIndex(0); $imagick->setImageFormat('jpg'); $imagick->scaleImage(770, null, true); return $imagick->getImageBlob(); }, 10, 2
The preceding code has not been tested, but it should give you an idea of how to achieve your goal.
There are many possibilities in Imagick, you could also crop the image.
Forum: Plugins
In reply to: [PDF Thumbnails] how to set size of thumbnail imageImages are generated using the built-in WordPress thumbnail features so that you can manage the sizes as described in the codex.
Forum: Plugins
In reply to: [PDF Thumbnails] HTTP ErrorHi,
I sent you an e-mail but haven’t received a response. From the phpinfo you posted it looks like ImageMagick is installed with PDF support so I don’t see any apparent reasons for why you should have problems with the plugin.
Generating the thumbnails requires some compute power, maybe you could try to upload some smaller PDFs to see if there is an improvement?
Forum: Plugins
In reply to: [PDF Thumbnails] Low resolutionImplemented in version 2.0.0, see main plugin page for documentation (used your fix as an example).
Forum: Plugins
In reply to: [PDF Thumbnails] Low resolutionThat makes sense. I think the best approach may be to add a filter that you can use to override the entire process with something like this:
add_filter('pdf_thumbnails_generate_image_blob', function ($pdfFilename) { $im = new Imagick(); $im->setResolution(200,200); $im->readImage($filename); $im->setIteratorIndex(0); $im->setImageFormat('jpg'); return $im->getImageBlob(); });
That will force you to do all the required Imagick configuration, but I think it will be more future proof than exposing the Imagick instance directly as I did in my first attempt. I will publish a new version sometime before next week.
Forum: Plugins
In reply to: [PDF Thumbnails] Low resolutionFrom what I found on the issue, it seems like the way you describe is the only way to make the text better, at least for JPEG images.
Updated the plugin with a new hook
pdf_thumbnails_before_get_image_blob
that you can use to modify theImagick
instance before image blob is generated, example in main plugin page.Forum: Plugins
In reply to: [PDF Thumbnails] Gallery with thumbnails linking to PDF filesAfter reading the post one more time, I see that you are adding the images and linking to PDFs, which seems like a more correct way to use the gallery function.
I suggest you take a look into how the gallery shortcode renders links. The
link
attribute is passed towp_get_attachment_link
which will filter the output through the wp_get_attachment_link filter. You should be able to override the attachment link there.In the
wp_get_attachment_link
filter, you can test if the image is a generated PDF thumbnail usingget_post_meta('PdfThumbnailsPlugin', self::META_KEY, true)
.EDIT: Removed the previous post, not relevant to the question.
Forum: Plugins
In reply to: [PDF Thumbnails] Need to rebuild thumbnail when i edit de pdf attachment postTwo months since last update, assuming that the issue was resolved.
Forum: Plugins
In reply to: [PDF Thumbnails] Woocommerce PDF upload folderThanks!
There are some hooks in the documentation. Unfortunately I don’t have any experience with WooCommerce and I did not find documentation on how they handle downloadable products.
If you have the ID for an attachment, you can manually generate a thumbnail using:
PdfThumbnailsPlugin::instance()->regenerateThumbnail($attachment_id);
Note that this is not a part of the official API and may be changed in the future.
If you find a useful hook, I’m happy to add integration code to the plugin as long as it is non-intrusive and does not deviate far from plugins main purpose.
Forum: Plugins
In reply to: [PDF Thumbnails] Bug: 'Invalid filename provided' when using HHVMThank you for the fix, works for regular PHP as well. Included in version 1.0.1.
Looks like you are missing the PHP extension for ImageMagick.
Yes, that is the install instructions, however, it is likely that the installation needs to be done by you hosting company. If it is a Linux-server, you (or the hosting company) can follow the PDF Thumbnails installation instructions.
Thank you for reporting the issue.
The warning means that the ImageMagick extension is unavailable and needs to be configured / installed. I’m using
extension_loaded('imageick')
to test if the extension is available (see PHP: extension_loaded). If the test fails (as it did in your case) the plugin will not try to generate PDFs.I see that your hosting company refers to binary ImageMagick files, not the PHP extension. Can you ask them to double check? The easiest way to get a definite answer is to run
phpinfo()
from a php-file and look for ImageMagick (or imagick),phpinfo()
will give you a list of all available extensions. This is something you can do as follows:1. Create a new file in your theme, name it “phpinfo.php”
2. Enter<?php phpinfo();
into the file
3. Access the file from https://YOURSITE/wp-content/themes/YOURTHEME/phpinfo.php
4. Search for imagemagick and report the results here (include all details about imagemagick)
5. Delete the file