Skip to main content
dublove
Legend
September 15, 2026
Question

Weird! Why is the content adaptation framework code ineffective for it?

  • September 15, 2026
  • 9 replies
  • 40 views

Please use the direct selection tool to select the innermost image.

The code is invalid for the blue image in the middle. Effective on the right side.


The reason for this may be that I held down "Ctrl+Shift+left mouse button" and dragged the innermost "image".

var d = app.activeDocument;
var item = d.selection[0];

//alert(item.constructor.name);
//alert(item.parent.parent.constructor.name);

// direct selection tool
if (item.constructor.name == "Image") {
//alert('000')
contentFitToFrame(item.parent.parent)
}

function contentFitToFrame(s) {
//alert('001')
s.frameFittingOptions.fittingAlignment = AnchorPoint.TOP_LEFT_ANCHOR;
s.fit(FitOptions.FILL_PROPORTIONALLY);
}

 

    9 replies

    rob day
    Community Expert
    Community Expert
    September 15, 2026

    ...

    rob day
    Community Expert
    Community Expert
    September 15, 2026

    This is another example of the problems you will run into with nested frames. Each frame has its own frameFittingOptions and fit methods, but you are only setting one of the two. You’ll get a different result If you set the parent and parent.parent, which in this case are rectangles:

     

    var d = app.activeDocument;
    var item = d.selection[0];

    if (item.constructor.name == "Image") {
    contentFitToFrame(item.parent)
    contentFitToFrame(item.parent.parent)
    }

    function contentFitToFrame(s) {
    s.frameFittingOptions.fittingAlignment = AnchorPoint.TOP_LEFT_ANCHOR;
    s.fit(FitOptions.FILL_PROPORTIONALLY);
    }

     

     

    dublove
    dubloveAuthor
    Legend
    September 15, 2026

    Hi ​@rob day 

    The problem doesn't lie here. Pay attention to the blue one, its function should be:
    contentFitToFrame(item.parent.parent)。
    But I don't know why it's contentFitToFrame (item. parent)

     

    The outermost frame of the original image is' item. parent '.
    Once pasted into the frame, its outermost frame is item.parent.parent

    rob day
    Community Expert
    Community Expert
    September 15, 2026

    Pay attention to the blue one

     

    My example is using the blue version in your 1028.indd file

    Community Expert
    September 15, 2026

    when you are pasting you are pasting the image with it parent rectangle. So for the centre image

    item.parent.parent is rectangle

    However for the left most image item.parent is rectangle and item.parent.parent is spread

    -Manan