Skip to main content
Todd_Morgan
Brainiac
September 6, 2024
Question

Please fix how RELINK TO FILE and REPLACE CONTENT work

  • September 6, 2024
  • 1 reply
  • 1216 views

RELINK TO FILE updates all instances of that asset. Good. But.... I want to swap out one layer with that asset with a french version. REPLACE CONTENT should do that... as it works, both of these right clicks do the same thing. PITA when working of a plethora of banners in english and then need to swap out layers (SOs) for french links IN THE SAME PSD FILE. Please get this going asap, or add a new right click that offers this. 

1 reply

Stephen Marsh
Community Expert
September 7, 2024

@Todd_Morgan – What you are complaining about is true:

 

https://helpx.adobe.com/au/photoshop/using/create-smart-objects.html#replace-smart-object-content

You can replace the image data in one Smart Object or multiple linked instances.


 

One needs to use the "New Smart Object Via Copy" command to isolate one particular embedded smart object so that it isn't synchronised.

 

There isn't such a native feature for linked smart objects, as they are linked, all links get replaced. I wrote a script to automate the creation of a "New Linked Smart Object via Copy", however it automatically saves a new linked file to break the path to the original linked file:

 

 
Another simpler option to automate this is to create a 5-step action to run on the linked smart object layer, where you can simply select the existing new file to replace:
 
1) Convert to Smart Object
2) Edit Contents
3) Select Relink to File menu item
4) Close - Saving: yes
5) Convert Smart Object to Layers
 
 
 
Here is a scripted version offering some extra features which are not available for actions:
 
/*
Relink to New Linked Smart Object via Copy.jsx
v1.0 - 9th September 2024, Stephen Marsh
NOTE: The script will relink to an existing file
https://community.adobe.com/t5/photoshop-ecosystem-discussions/please-fix-how-relink-to-file-and-replace-content-work/td-p/14846535
Related to:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/why-is-new-smart-object-via-copy-greyed-out-for-linked-smart-objects/td-p/14371680
*/

#target photoshop

try {

    // Smart object action manager properties
    var ref = new ActionReference();
    ref.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("smartObject"));
    ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
    var so = executeActionGet(ref).getObjectValue(stringIDToTypeID("smartObject"));

    // Conditional check for the active layer being a linked smart object
    if (so.getBoolean(stringIDToTypeID("linked"))) {
        // Single history stage undo
        activeDocument.suspendHistory("Relink to New Linked Smart Object via Copy.jsx", "main()");
    }

} catch (err) {
    alert("Error!" + "\r" + err + "\r" + 'Line: ' + err.line);
}

function main() {

    try {

        // Convert the active linked smart object layer to an embedded smart object
        executeAction(stringIDToTypeID("newPlacedLayer"), undefined, DialogModes.NO);

        // Edit the smart object contents
        executeAction(stringIDToTypeID("placedLayerEditContents"), new ActionDescriptor(), DialogModes.NO);

        // Relink to file
        var idselect = stringIDToTypeID("select");
        var desc350 = new ActionDescriptor();
        var idnull = stringIDToTypeID("null");
        var ref59 = new ActionReference();
        var idmenuItemClass = stringIDToTypeID("menuItemClass");
        var idmenuItemType = stringIDToTypeID("menuItemType");
        var idplacedLayerRelinkToFile = stringIDToTypeID("placedLayerRelinkToFile");
        ref59.putEnumerated(idmenuItemClass, idmenuItemType, idplacedLayerRelinkToFile);
        desc350.putReference(idnull, ref59);
        executeAction(idselect, desc350, DialogModes.ALL);

        // Get the layer name
        var layerName = app.activeDocument.activeLayer.name;

        // Close and save
        app.activeDocument.close(SaveOptions.SAVECHANGES);

        // Convert the embedded smart object back to a linked smart object
        executeAction(stringIDToTypeID("placedLayerConvertToLayers"), undefined, DialogModes.NO);

        // Set the layer name
        app.activeDocument.activeLayer.name = layerName;

    } catch (err) {
        alert("Error!" + "\r" + err + "\r" + 'Line: ' + err.line);
    }

}
 
P.S. You can add a feature request by marking a new topic as an "idea" rather than as a "discussion".
Todd_Morgan
Brainiac
September 13, 2024

That is not true, all links do not get replaced. For example, if I copy/paste a SO from one artboard to another, that file is no longer "linked" so if I edit that new SO the original does not change, but if I relink to file and update that said SO they all change - which is very weird. Also, if I drag clone/copy a SO from one artboard to next, then when I do edit that new SO the original one also updates. There really seems like there's no rhyme or reason as to how SO and changing content works and Adobe needs to revisit this with to clear and critical thinking to fix in the next update.

Brainiac
September 17, 2024

assume....


Yes, that's what you've done. I see no evidence of a bug. Where is your proof that this is not working as designed?