0

I have a client site in which I need to convert a very large number of existing entries from ExpressionEngine's native File Upload functionality to Assets in order to take advantage of S3 storage. I have successfully converted all File fields to Assets fields and moved over the files to S3 via drag and drop in the Assets interface. Now all of those fields are properly pointing to S3.

The problem comes in with Wygwam fields. I have referred to this other SO answer which explains that previous to Wygwam 2.7 there was no way for Assets to keep track of what files were pointed to inside Wygwam fields. I have upgraded the site's Wygwam version to 2.7.

I wrote a batch process that does a regex replace on the contents of all wygwam fields and converts {filedir_n} and hardcoded references to {asset_m} references for the corresponding Assets S3 upload location. Now all of them simply display {asset_m}/filename.ext, which obviously means broken images.

It was my understanding that Wygwam 2.7 would be able to convert those tags on display to the correct path. Am I missing something?

1

It turns out that the linked SO answer referred incorrectly to {asset_n} tags as opposed to {assets_n} with the "s". This was part of the answer.

The rest of it is that Wygwam expects the assets file to be referred to as {assets_<file_id>:<fallback_url>}. Importantly, the number refers to the file id in table exp_assets_files not the source_id in exp_assets_sources. The presence of the fallback url seems to be for when assets is uninstalled, or when the file reference no longer exists. You should be able to leave it blank eg. {assets_237:} but I haven't tested this.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.