Skip to main content
Participating Frequently
March 7, 2022
Answered

How to get image's path in before place event

  • March 7, 2022
  • 1 reply
  • 730 views

Hi,

I am creating a small utility which checks for special characters in image names when a image is placed inside any rectangle. If there is any special character then it throws up an dialog asking user rename the image.

I am not sure how to get the image name or path in the before place event. Events target is rectangle and the image has yet not been placed so i don't have access to image link there in the rectangle.

This topic has been closed for replies.
Correct answer Manan Joshi

The following should work

#targetengine "test"
app.documents[0].addEventListener('beforeImport', function(e){
	alert(e.fullName)
	//Check you condition and if it fails, cancel the event
	e.preventDefault()
})

-Manan

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
March 7, 2022

The following should work

#targetengine "test"
app.documents[0].addEventListener('beforeImport', function(e){
	alert(e.fullName)
	//Check you condition and if it fails, cancel the event
	e.preventDefault()
})

-Manan

-Manan
Ujjwal_u2Author
Participating Frequently
March 7, 2022

Hi Manan, i have already done this. my question here is inside which object or property of the event object can i access the images path or name or links path.

Community Expert
March 7, 2022

Didn't you notice the alert, the alert is giving the full path of the image that you are trying to place. If the path does not meet your criteria just cancel the event.

-Manan

-Manan