Be sure to checkout our newest add-on, Speedy — Advanced Caching for ExpressionEngine.

Compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field (it's in the works).

Ticket: Expressionengine preview does not render assets within bloqs

Status Resolved
Add-on / Version Bloqs 4.1.1
Severity
EE Version 5.3.0

Est Digital

Nov 27, 2019

Expressionengine preview does not render assets within bloqs. the {if image} statement returns false because the value is empty in the preview. I’ve done some digging and noticed that the $adapter->getBlocksFromPost in ft.bloqs.php row 440 does not return assets values. The $this->getBlocks function does return assets values but only shows data from the saved entry, and not the unsaved/changed data in the preview (from post). Could you modify the getBlocksFromPost to return the assets data aswell?

EE 5.3.0
Bloqs 4.1.1
Assets 3.3.3

#1

BoldMinded (Brian)

Nov 27, 2019

Hi there. Thanks for the report. Unfortunately I can’t make it work. If you are adding a new file to an Assets field, it does not yet exist in the $_POST array, or anywhere on the local filesystem other than in a /tmp directory. This isn’t only an issue for Bloqs, but an issue for Assets itself. If you add a normal Assets field to an entry (not in Matrix/Grid/Bloqs), create a new entry and add a file to the field, then attempt to preview it, you’ll see that the image doesn’t work there either. Hopefully this is something that can be fixed in Assets or in EE itself in the upcoming versions, but for now, Assets file previews only work if the file is already attached to an entry.

#2

BoldMinded (Brian)

Nov 27, 2019

Jelle, can you respond in the ticket please, not directly to the email.

That’s not totaly true, even editing entries with assets images in bloqs does not show them. I also saw in the post data that the file field is posted with an file_id which is in exp_assets_files if an existing image is chosen. For new images your point is valid.

I just tested it locally, with an EE File field, and Assets field. The Assets field was pulling images from S3.

#3

BoldMinded (Brian)

Nov 27, 2019

I messed up the first test and will take another look at this.

#4

BoldMinded (Brian)

Nov 27, 2019

This probably isn’t something I’ll have a quick fix for… could be a few days or a couple weeks.

#5

BoldMinded (Brian)

Nov 27, 2019

Are you using Publisher with this site?

#6

Est Digital

Nov 27, 2019

Hi, not im not using publisher, would that fix the problem?

#7

BoldMinded (Brian)

Nov 27, 2019

No it won’t fix it. I’m just trying to debug it.

#8

BoldMinded (Brian)

Nov 27, 2019

I do see the issue, but I also see following code in the getBlocksFromPost() method appears to correctly set the value of the Assets field. I’ll dig into it more, but to confirm, when I save an entry the Assets image is not displayed in the Preview, which it should.

foreach ($blockData['values'] as $columnId => $columnValue) {
                $atomDefinitionId = (int) str_replace('col_id_', '', $columnId);
                /** @var AtomDefinition $atomDefinition */
                $atomDefinition = $this->findWhere($atomDefinitions, ['id' => $atomDefinitionId]);

                $atom = new Atom();
                $atom
                    ->setId($atomId)
                    ->setValue($columnValue)
                    ->setDefinition($atomDefinition)
                ;

                $currentBlock->addAtom($atomDefinition->shortname, $atom);

                $atomId++;
            }
#9

BoldMinded (Brian)

Nov 27, 2019

So, I talked to Jace at EE Harbor, and confirmed that Assets does not officially support Live Preview, and may not for some time (they’re focused on EE6 right now). If an Assets field works in LP in as a standalone field it is basically by dumb luck (b/c it already contains the full path to an image in a saved entry). A standalone field is very different than Bloqs or Grid. Basically if Assets doesn’t officially support LP, then I can’t officially support it inside of Bloqs either. Probably not what you want to hear, but there isn’t much I can do :/

#10

BoldMinded (Brian)

7 days ago

Closing this ticket b/c it isn’t something I can fix.

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.