Skip to content

[5.x]: Assets are uploaded to (and remain) in a temp-xxx… folder if {slug} is used in the asset upload path for entry types with auto-generated titles #16799

@rungta

Description

@rungta

What happened?

Description

Craft appears to be delaying auto-generating the slug field until the first Save operation for entry types that don’t use the native title field. This leads to poor AX for asset fields that use {slug} in the upload path.

In the absence of a slug, Craft ends up creating temporary asset folders and any assets uploaded before the first-save end up remaining in these temp-xxx… folders, even after a slug has been generated for the entry (automatically by Craft).

Steps to reproduce

  1. Create an entry type with an auto-generated title using a custom title field (example screenshot below)
  2. Create an asset field with {slug} in the Default Upload Location setting.
  3. Add this asset field to the entry type from step 1.
  4. Create a new entry for the entry type from step 1
    • Upload a file to the asset field from step 2
    • Entry “Foo Bar” in the custom title field
    • Do not manually fill in the slug field
  5. Save the entry

Image
Image
Image

Expected behavior

Expected behavior is that the asset uploaded in step 4 will be saved inside a folder called foo-bar.

Actual behavior

Instead, the asset is found inside a folder called temp_eqzxinrledslkmppbcjqgtbddqemrexmtvem.

Craft CMS version

5.6.5.1

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions