4

After some research I found out that this problem has no simple solution (unfortunately). Check https://github.com/smcyr/Craft-FocusPoint/issues/10. A solution would be not to use eager loading (obvious). Another solution could be using Craft3 (no plugin needed). The solution I used was Focal Point (https://github.com/aelvan/FocalPointField-Craft). Focal ...


4

When using the for loop you don't need to set image as it is set in the for loop. You will also need to define transformedImage on every iteration, so move it within the for loop. Give the below a go, it should do what you are after. <div id="header-slider"> <ul> {% for image in entry.bannerSlider %} {% set transformedImage = craft....


3

Eager loading is used to reduce the number of database queries. Imager doesn't store any data in the database, it's completely file-based, so it's not relevant to use eager-loading in relation to it.


3

Unfortunately, resizing images always tends to make them a little bit blurry, especially if the size that it's resized from isn't very big. But, here's a few things you can try: Make sure you're using the Imagick image driver in Craft, that gives you alot more options to play with ('imageDriver' => 'imagick' in your general config). Try playing around ...


3

In yii2 every instance of a module is stored in a public static property of the main class. If the plugin is called image you can grab it via Imager::getInstance() This instance contains all the required components. The imager plugin it has 3 components $this->setComponents([ 'imager' => ImagerService::class, 'placeholder' => ...


3

You’re currently passing in the image model you queried for using first() into the craft.imager.transformImage function, but you actually need to pass in the models that you get when looping through all images added to your block’s field. There’s no reason to do the first() at all, and it would add additional queries. {% if block.image|lenght %} {% for ...


3

I don't know if it's the cause of the error you're receiving or not, but this is incorrect Twig syntax: {% set image = '{{ websitePreferences.placeholderImage.first.url }}' %} You'll never need to nest {{ }} inside of {% %} or visa versa in Twig. This is correct: {% set image = websitePreferences.placeholderImage.first() %}


2

Turns out google chrome dev tools was lying to me when i hovered over the images in a srcset and told me their natural size was different to their real size. All working grand!


2

It depends on the type of errors that are being thrown. If they are Twig/template errors, then you can can set the suppressTemplateErrors config setting to true and they will simply get logged and the page request will continue as usual. If they are non-Twig exceptions, then you'd have to do something more fancy like make a plugin that's essentially a ...


2

I've managed to get it working via the following steps: Create a new field and give it the preparse field type Duplicate only the twig variable code from the template into the input box in the field page. In Craft Settings, go to the page template, and add the new preparse field to the available fields (this doesn't show up in the content editor). The twig ...


2

Problem solved: imagerSystemPath was set relatively


2

This is all pretty well documented here: Creating Optimized Images in Craft CMS But if you need general help on srcset and <picture> elements check out Responsive Images Done Right: A Guide To And srcset and Don’t use (most of the time)


2

I ran into this issue too and had landed on this thread (and another similar one). I was able to piece together a solution using the modify elements query method. I wrote a pull request that got merged, so lazy-loading works with this plugin as of version 1.1.4.


2

Assuming it's the field portfolioImage that can have multiple assets, try this: {% for block in entry.portfolio %} {% switch block.type %} {% case "images" %} {% for image in block.portfolioImage %} {% set transformedImages = craft.imager.transformImage(image, [ { width: 1200, ratio: 4/3 }, { ...


2

I've had the same problem. You can do it by creating a custom plugin that returns image transform info. Look here => Get a defined image-transform's width and height in front-end template


2

You'll have to define your transforms inline - Imager doesn't support named (i.e. CP-/admin-defined) transforms.


2

Your issue is that Craft (or rather, Imager) is not treating your entry.cropPosition Dropdown field as a string; you're essentially passing the actual DropdownFieldType model (an array like object). To fix it, replace position: entry.cropPosition with position: entry.cropPosition.value Also, you might want to add a default value to the field, in case ...


2

If the value of imageCrop is a string in the correct format (ie 50% 50%, 0% 0%, or similar), this should do it: {% set entryImage = entry.pageHeader.first() %} {% set imageCrop = entryImage.cropPosition %} {% set transformedImages = craft.imager.transformImage(entryImage, [ { width: 1680, jpegQuality: 75 }, { width: 1080, jpegQuality: 75 }, { ...


2

Craft's built-in transform functionality doesn't support transforming external URLs. You could use my Imager plugin to do this instead. EDIT: Based on your example, you'd use Imager something like this: {% set response = craft.twitter.get('statuses/user_timeline', { tweet_mode:'extended', count: 20 }) %} {% if response.success %} {% for tweet in ...


2

Why do you try to fetch the image multiple times? {% for image in block.logos %} Will fetch the images and loop them {% set logo = block.logos.first() %} -> will fetch the first image again and again. {% for image in block.logos %} {% set transformedImage = craft.imager.transformImage(image, { width: 312, height: 200, }) %} <img src="{{ ...


2

As noted in the comments, sounds like you've got an error in your Imager config (prob an incorrect value set for the imgixEnablePurgeElementAction option or one of the lines close by).


2

Have a look a little further down in the Readme and you will see more information regarding Watermark. From the Readme... image: The image that is to be used as watermark. Just as the image parameter in the craft.imager.transformImage method, this can be an AssetFileModel, a string to a previously transformed Imager image, or a string to an external image. ...


2

1. If you need a rotated version of an image but Imager can't transform the image programmatically, you could just create 2 different asset fields for the same image. One field for the landscape orientation, and the other for portrait. In that table view example you showed above I'd imagine you would need 2 columns: Image Landscape and Image Portrait. ...


2

Your variable assignment is wrong. {% set customRatio == 1/1 %} should be {% set customRatio = 1/1 %}.


1

Solved the complete error with a reset of the imager config file.


1

Imager will always create and store the transformed images locally in your imagerSystemPath, even if you choose to upload and serve them from an external storage. The files in that folder acts as the cache, so that Imager knows if a transform has been created or not. Alternatively, Imager either would have to; 1) make a request for each transformed image ...


1

So the problem is that you're using an example from my older article, which was written for Craft 2.x. This line: craft()->config->set('generateTransformsBeforePageLoad', true); ...and also these lines: if (craft()->plugins->getPlugin('Imager')) { $image = craft()->imager->transformImage($srcImage, [ ...are specific to Craft 2.x; ...


1

It looks like the sizes attribute needs to be tweaked. Absolute image sizes need to be specified in px units, not w. <img src="{{ craft.imager.base64Pixel(16, 9) }}" sizes="(min-width:641px) 400px, 100vw" srcset="{{ craft.imager.srcset(transformedImages) }}" class="{{ imageClass }}"> The way the browser reads sizes is left to right ...


1

The error appears to be coming from the Imager plugin: https://github.com/aelvan/Imager-Craft/blob/master/imager/services/ImagerService.php#L1025 Make sure you're using the latest version, and then potentially post an issue here: https://github.com/aelvan/Imager-Craft/issues


1

When you use the Twig curly brace {}, key/value pair syntax like you've got imagerConfig set to, you're using the Twig hash literal. In Twig, if you want to add to an array or hash after it has already been created, you can use the merge filter. Something like this should do what you're looking for: {% set imagerConfig = { jpegQuality: 80, ...


Only top voted, non community-wiki answers of a minimum length are eligible