Sub topic 6
Swapping designs with Replace Contents
This chapter covers Replace Contents, the command that swaps the artwork inside a smart object and keeps the transforms, masks and effects around it. It assumes you can work with layers, groups and masks, and that you know what a smart object is. It also assumes you have built a placeholder and edited its contents, as covered in earlier chapters.
What Replace Contents does
A smart object stores its source data separately from the layer that displays it. Replace Contents swaps that stored source for another file. Everything applied to the layer stays in place: the Free Transform, Distort or Warp, the layer mask, blend mode, opacity, layer styles and smart filters.
Compare this with two other ways of changing a design:
| Method | Transform kept | Smart filters kept | Other smart object copies updated |
|---|---|---|---|
| Edit Contents, then save | Yes | Yes | Yes, if the layer was duplicated as a linked copy |
| Replace Contents | Yes | Yes | Only linked copies that share the same source |
| Delete layer and place a new file | No | No | No |
The last row is why mockups use Replace Contents. A new placed file arrives with none of the perspective work you did.
Running the command
- In the Layers panel, select the smart object layer, for example
Artwork. - Choose Layer > Smart Objects > Replace Contents....
- Pick the new file in the dialog and click Place.
- Check the result in the canvas.
You can also right-click the layer and choose Replace Contents.... The command is unavailable if the selected layer is not a smart object, or if several layers are selected.
Photoshop accepts raster images (PNG, JPEG, TIFF, PSD), vector files (AI, PDF, SVG) and other documents that Photoshop can place. A PSD with layers is placed as a flattened composite unless you convert it first.
How the new file is scaled
Replace Contents does not simply drop the new file at its native size. Photoshop scales the incoming content so it matches the bounds of the existing smart object, and the placement depends on the aspect ratio:
- If the new file has the same aspect ratio as the old contents, it fills the same area.
- If the aspect ratio differs, Photoshop fits the new file inside the old bounds and leaves empty space on the short side. It does not crop.
- If the new file has a different pixel size but the same ratio, it is scaled to match, so the displayed size on the mockup stays constant.
Because of this behaviour, the cleanest workflow is to prepare every design at the same pixel dimensions and ratio as the placeholder's contents. The previous chapter covered how to size artwork. If a design is smaller in pixels than the placeholder, Photoshop upsamples it and the result looks soft.
What happens inside the smart object
When you open the smart object with Edit Contents, you see a separate document. After a replacement, that document holds the new file as a single layer. Any layers you built in the original contents, such as guides, a background fill or a bleed area, are gone. Replace Contents discards the previous inner document and does not merge with it.
If your mockup depends on inner structure, for example a die-line for a box or a safe area, keep that structure in the designs themselves. Otherwise place it in the scene document as a layer above or below the smart object.
Worked example: a poster mockup
Suppose a scene document has a framed poster on a wall. The Artwork layer is a smart object with a Perspective transform and a mask that hides the frame edge. A multiply layer called Wall shadow sits above it, clipped to it.
Prepare three designs, each at 3000 × 4000 px and in sRGB:
poster-01.pngposter-02.pngposter-03.png
For each design:
- Select
Artwork. - Run Replace Contents and pick the file.
- Confirm the perspective, mask and shadow still line up.
- Export the image.
Because the transform lives on the layer, not in the contents, all three exports share identical geometry. Only the design differs.
Linked copies and shared sources
A smart object can be duplicated in two ways, and the difference matters for replacement.
- Duplicate Layer (Layer > Duplicate Layer, or dragging to the new layer icon) creates a copy that still points to the same source. Changing the contents of one updates all of them.
- New Smart Object via Copy (Layer > Smart Objects > New Smart Object via Copy) creates an independent copy with its own source. Replacing one does not affect the other.
Mockups with several surfaces, such as the front and back of a cereal box or a pattern repeated across a set of mugs, usually want the first kind. Replace Contents on one layer then updates every linked copy at once. If you need different designs on different surfaces, use the second kind and replace each layer separately.
To check which kind you have, open one layer with Edit Contents, change something visible and save. If the other layer updates, they share a source.
Embedded and linked files
Replace Contents works on both embedded and linked smart objects, but the result is different.
- With an embedded smart object, the new file is copied into the PSD. The original file on disk is no longer needed.
- With a linked smart object, the layer points to the new file on disk. Moving or renaming that file later breaks the link.
If the mockup is going to another person, embedded avoids missing-file warnings. Linked is better when you edit the design in another application and want the mockup to pick up changes. A later chapter covers the choice in more detail.
Keeping the replacement realistic
Replace Contents changes only the content. Things that depend on the content can still look wrong.
- Color. A design in a different profile will shift when displayed. Convert designs to the document profile before placing, or choose Edit > Convert to Profile in the smart object.
- Contrast against shadows. A very dark design can make a multiply shadow invisible. A very light design can make a screen highlight blow out. Check both extremes.
- Edges. A design with a transparent border shows the scene behind it. A design with a white border looks like a margin. Decide which you want and prepare files to match.
- Smart filters. A Gaussian Blur or Noise filter applied to the smart object runs again on the new content. This is usually what you want, but a filter tuned to one design, such as a sharpening amount, may need a second look.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| The command is greyed out | The selected layer is not a smart object, or more than one layer is selected | Select one smart object layer |
| New design is smaller than the frame | Different aspect ratio | Resize the canvas of the design to the placeholder ratio |
| Design looks soft | Source has fewer pixels than the placeholder | Export designs at the placeholder's size or larger |
| Layers from the old contents have vanished | Replace Contents discards the inner document | Keep guides in the scene document |
| Only one of two surfaces updated | The layers are independent copies | Use Duplicate Layer to create linked copies |
| A "missing linked file" warning appears | A linked source was moved | Use Layer > Smart Objects > Relink to File |
Replacing from a script
When you have many designs, repeating the dialog is slow. The Replace Contents command can be run from ExtendScript through the Action Manager event placedLayerReplaceContents. The script below selects the layer by name, replaces its contents and saves a JPEG copy.
#target photoshop
var doc = app.activeDocument;
var artworkFile = new File("~/mockups/art/poster-01.png");
var outFile = new File("~/mockups/out/poster-01.jpg");
// Select the placeholder smart object by layer name (top-level layer).
doc.activeLayer = doc.layers.getByName("Artwork");
// Replace its contents with the new artwork file.
var desc = new ActionDescriptor();
desc.putPath(charIDToTypeID("null"), artworkFile);
desc.putInteger(charIDToTypeID("PgNm"), 1);
executeAction(stringIDToTypeID("placedLayerReplaceContents"), desc, DialogModes.NO);
// Save a JPEG copy of the finished mockup.
var opts = new JPEGSaveOptions();
opts.quality = 10;
doc.saveAs(outFile, opts, true, Extension.LOWERCASE);The layer must sit at the top level of the layer stack. For a layer inside a group, look it up through that group's layers collection. The PgNm value selects the page when the file has several, such as a multi-page PDF. A later chapter extends this into a loop over a folder.
Checklist
Before sending a mockup out, confirm these points for each replacement:
- The designs share one pixel size, ratio and color profile.
- The right layer was selected, and it is a smart object.
- The perspective, mask and shadows still match the surface.
- Linked copies updated, or intentionally did not.
- Any link to an external file is still valid.
Exercise
You have a mockup with two smart object layers, Front and Back, both made with New Smart Object via Copy. You run Replace Contents on Front with a new design. What happens to Back, and how would you change the setup so one replacement updated both?
Show answer
Back is unchanged, because New Smart Object via Copy gives each layer its own source. To make one replacement update both, delete Back and recreate it with Layer > Duplicate Layer from Front, so both layers share a single source. Then reapply the transform and mask for the back surface.
Exercise
A replacement design has a 1:1 ratio, but the placeholder's contents are 3:4. What does Replace Contents do, and how do you avoid the result?
Show answer
Photoshop fits the square design inside the 3:4 bounds without cropping, which leaves empty space on the short side. To avoid it, resize the design's canvas to 3:4 before replacing, for example 3000 × 4000 px, and place the artwork inside that area.