Sub topic 12
Replacing Contents and Building Mockups
This chapter assumes you can create smart objects, edit their contents, and apply transforms, as covered in earlier chapters. It also assumes you are comfortable with layer masks and the Layers panel. Here you will use Replace Contents to swap one image for another while keeping the transforms and smart filters on the layer. You will then use that to build a reusable mockup.
Why replacing contents works
A smart object layer keeps two separate things:
- The contents: the embedded or linked source pixels or vectors.
- The layer state: position, scale, rotation, warp, smart filters, the smart filter mask, layer masks, blend mode, opacity, and layer styles.
Replace Contents swaps the first and leaves the second alone. This is the basis of mockup templates. You design the perspective, shadows, lighting, and texture once. After that, each new design only needs a new source file.
The command is Layer > Smart Objects > Replace Contents.... You can also right-click the layer and choose Replace Contents.... Photoshop opens a file dialog, and you pick the new file.
What is kept and what changes
| Item on the layer | After Replace Contents |
|---|---|
| Position of the layer's center | Kept |
| Scale, rotation, skew, perspective, warp | Kept, but applied to the new content's size (see below) |
| Smart filters and the smart filter mask | Kept and re-applied to the new content |
| Layer mask, blend mode, opacity, layer styles | Kept |
| Layer name | Usually kept, but see the note on names below |
| Source pixels or vectors | Replaced |
| Edits made inside the old source | Lost with the old source |
The last row matters. If you painted or adjusted anything inside the old smart object, that work belongs to the old source. It will not carry over to the new one.
Size and aspect ratio
Photoshop tries to fit the new content into the same bounding box as the old content. If the new file has a different aspect ratio, it is fitted to that box. This can leave empty space on one side, or it can make the content look scaled differently than you expect.
Two practical rules help:
- Prepare replacement files at the same pixel dimensions and aspect ratio as the original source. A mockup with a 2000 by 1500 pixel placeholder works best with 2000 by 1500 pixel designs.
- Keep the placeholder at or above the resolution you need for the final output. The transform scales the source, so a small source scaled up will look soft.
If a replacement still lands at the wrong size, double-click the layer thumbnail to open the contents and check the canvas size there. You can also resize the new file before replacing it.
Building a mockup step by step
This walkthrough builds a simple poster mockup. The photo shows a wall with a blank frame, and you will place a design into the frame.
- Open the scene. Open the photo of the framed wall. Keep it as the background layer.
- Create a placeholder. Place a design file with File > Place Embedded.... Any image works for now. The placed layer becomes a smart object.
- Match the frame's perspective. Use Edit > Transform > Distort, or Edit > Transform > Perspective, and drag each corner to a corner of the frame. For curved surfaces, use Edit > Transform > Warp. Because the layer is a smart object, you can redo this as often as you like with no cumulative loss.
- Add realism. Set the layer's blend mode to Multiply so shadows and wall texture show through. Lower the opacity a little if the design looks too flat.
- Add a smart filter if needed. A small Gaussian Blur of about 0.5 pixels softens the edges. Because it is a smart filter, it stays editable and is re-applied after every replacement.
- Save the mockup as a PSD. This is your template.
- Swap designs. Select the smart object layer and choose Layer > Smart Objects > Replace Contents.... Pick a new design. Perspective, blend mode, and blur remain in place.
- Export. Use File > Export > Export As... for each finished version.
Working inside the smart object
Sometimes the design itself needs to match the scene, for example a design with its own layers. Double-click the smart object thumbnail to open the contents in a separate document. Edit there, then save with File > Save (Ctrl+S or Cmd+S). The mockup updates when you save.
Many mockup authors set this up on purpose. The placeholder file contains a guide layer that says "Place your design here" and a note about the safe area. Whoever uses the mockup then opens the contents, pastes their work in, and saves.
Replace Contents with linked smart objects
Replace Contents works on linked smart objects too. The result is a layer that points to the new file. Keep these points in mind:
- The new file is linked, not embedded. If you move or delete it, the link breaks.
- If you want a self-contained template, convert the layer to embedded first with Layer > Smart Objects > Embed Linked.
- Linked files are convenient when the design changes often. If you save the linked file in its own application, the mockup updates the next time Photoshop checks it, with no Replace Contents step needed.
Replacing several copies at once
If you duplicated a smart object with Layer > New > Layer via Copy (or Ctrl+J / Cmd+J), the copies share one source. Replacing the contents of one replaces all of them. This suits a mockup showing the same design on a front and back view.
If you want different designs on each, use Layer > Smart Objects > New Smart Object via Copy. That command makes an independent copy with its own source, so replacing one leaves the other unchanged.
Common errors
- The replaced image looks stretched. The new file has a different aspect ratio. Resize the replacement file to match the placeholder, or fix the canvas inside the smart object.
- The result looks blurry. The placeholder was small, or the replacement is small and the transform enlarges it. Use a larger source.
- Nothing changed when you replaced. Check that you selected the correct layer. When several smart objects share a source, you may have changed more than you expected.
- The wrong design appears on two layers. The layers share a source because they were made with Layer via Copy. Use New Smart Object via Copy next time.
- Filters look different after replacing. Smart filters are recomputed on the new pixels. A blur radius that suited one image may be too strong or too weak for another. Open the filter by double-clicking its name in the Layers panel and adjust it.
- Replace Contents is greyed out. You have more than one layer selected, or the selected layer is not a smart object. Select one smart object layer.
A short script
For batch work you can trigger Replace Contents through ExtendScript. This example swaps the active smart object layer's contents for a file you choose.
// Photoshop ExtendScript: replace the active smart object's contents
var file = File.openDialog("Choose the replacement design");
if (file) {
var desc = new ActionDescriptor();
desc.putPath(charIDToTypeID("null"), file);
executeAction(stringIDToTypeID("placedLayerReplaceContents"), desc, DialogModes.NO);
}Select a single smart object layer before running it. If the layer is not a smart object, Photoshop reports an error.
Checklist for a reliable template
- Name the placeholder layer clearly, such as "Design here".
- Keep the placeholder at the final target resolution.
- Store a note inside the smart object that states the required dimensions.
- Save the PSD with the smart object embedded if you will share it.
- Test the template with two different designs before you distribute it.
Exercise
You built a mockup with one embedded smart object that has a Multiply blend mode, a perspective transform, and a 0.5 pixel Gaussian Blur smart filter. You use Replace Contents with a new design. Which of those three settings are lost, and what do you do if the design appears stretched?
Show answer
None of the three are lost. The blend mode, the transform, and the smart filter all stay on the layer and are re-applied to the new content. If the design appears stretched, its aspect ratio differs from the placeholder's. Resize the replacement file to the placeholder's pixel dimensions and aspect ratio, then replace the contents again.
Exercise
A mockup has a front view and a back view, each a copy of the same smart object made with Layer via Copy. You replace the contents of the front view and both views change. How do you get different designs on each view?
Show answer
Layer via Copy creates copies that share one source, so replacing one replaces all. Delete the back copy and create it again with Layer > Smart Objects > New Smart Object via Copy. That gives it an independent source, so you can replace its contents separately.