Let’s say I hav an image my_image.jpg in the database top group _assets. For referencing the image in a Markdown document I write

When I have selected my_image.jpg how can I get the path /_assets/my_image.jpg into the cipboard to use it in my Markdown doic?
Side note: I do *not want to use the Item link (like x-devonthink-item://1CFEEAAD-ED87-49CE-9980-AE36289DC5F3, because if I look at my Markdown file, it is far more readable with /_assets/my_image.jpg than with x-devonthink-item://1CFEEAAD....
Where is your Assets group?
If it’s a subgroup of the group your Markdown document is in, drag and dropping the image into the Markdown document should insert the relative link, e.g.,…
-- Copy location and name
tell application id "DNtp"
try
set theRecords to selected records
if theRecords = {} then error "Please select some records."
set theLocationAndNames to {}
repeat with thisRecord in theRecords
set thisRecord_Location to location of thisRecord
set thisRecord_Name to name of thisRecord
if thisRecord_Name contains "/" then set thisRecord_Name to my escapeSlash(thisRecord_Name)
set thisLocationAndName to (thisRecord_Location & thisRecord_Name) as string
set end of theLocationAndNames to thisLocationAndName
end repeat
set theLocationAndNames_string to my tid(theLocationAndNames, linefeed)
set the clipboard to theLocationAndNames_string
display notification theLocationAndNames_string with title "Copied"
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
on escapeSlash(theText)
set d to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set theTextItems to every text item of theText
set AppleScript's text item delimiters to "\\/"
set theText_escaped to theTextItems as string
set AppleScript's text item delimiters to d
return theText_escaped
end escapeSlash
on tid(theInput, theDelimiter)
set d to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelimiter
if class of theInput = text then
set theOutput to text items of theInput
else if class of theInput = list then
set theOutput to theInput as text
end if
set AppleScript's text item delimiters to d
return theOutput
end tid