4

How does one go about building a dynamic link to a file managed by Assets within a Wygwam field?

In other words, when we move our EE project from dev.example.com/projects/project_name to example.com, will we have to go back into Wygwam and update all of our paths to any PDFs or images that were linked to within our Wygwam fields, or is there a way to build those links (perhaps using {path}?) so they don't break?

5

I'm hoping I'm getting this right. I'm not a Wygwam/Assets expert, so... The way we have handled it is by setting our EE file upload preferences 'URL of Upload Directory' settings with the relative path from the web root. For example:

'/images/article_images/'

I believe Wygwam then uses the {fieldir_1} syntax when it saves the image path, so in the channel data it gets a path like:

{filedir_1}myimage.jpg

Then when it is processed in the template the image path becomes:

<img src="/images/article_images/myimage.jpg" />
1
  • 1
    This is correct. And if you’re on Assets 2 + Wygwam 2.7, the URLs of any files you selected via the Assets selection modal will even be updated when you move/rename the files from Assets. – Brandon Kelly Jan 26 '13 at 23:50

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.