I have setup a page that has image asset pickers on it and image asset pickers in a matrix field.
I have setup the fields to allow a single directory and a { slug } for the normal field pickers and { owner.slug } for the matrix field destinations.
So far so good, if I work with a saved page it all works beautifully, the images get saved in the folder with the name of the page :)
But it doesn't seem to work for a new page, when I pick an image the dialog that comes up does not show the { slug } folder and when upload and select an image it shows a broken image in live preview mode. Once I save the page and go back in it all comes good.
Ok my description was poor, I am certain this is a bug, here are the details...
- I have an asset repository called property-images
- I have a section template with 2 image fields mainImage, searchImage and another image inside a matrix field
- mainImage and searchImage are set to use a single source (property-images) with the location set to {slug}
- the matrix image is the same with the location set to {owner.slug}
I create a new page and save it (so the page is created and has a slug) I go back into the page and select mainImage, it works beautifully, and loads images into a sub folder correctly. If i create a new matrix block and select an image, I don't get the asset in my sub folder display but some sort of tmpassets folder. OK I kind if get this, because the block isn't created yet, I don't like it but I can live with it. Now when I look at live preview the image doesn't preview, the image url it renders doesn't exist.
So I save my page and come back in...
Now the image I picked in the block has been moved to the correct assets folder but still doesn't render anything, the transformed images aren't there
If I remove the image from the matrix block and re-pick it now it all works fine.
So it seems to explain to the content editor how to use this I need to tell them whenever they create a new matrix block they need to publish the page and come back in and then pick the image and then it's good. I can tell you that is not going to fly with this client!
I've also experimented with a page in draft but a different set of weird things results.
Oh one more thing! I'm using transforms in code, so something like:
{% set lrg = { mode: 'crop', width: 1400, height: 866, quality: 75, position: 'center-center' } %}
img src='{{ image.getUrl(lrg) }}'
I wonder if predefined transforms are better?