news::markdown_image::drafts (private)

 news::markdown_image::drafts content format

Defined in packages/news/tcl/markdown-image-procs.tcl

Collect this editor's staged images referenced by the article HTML.

Parameters:
content (required)
format (required)

Partial Call Graph (max 5 caller/called nodes):
news::markdown_image::require_drafts news::markdown_image::require_drafts (private) news::markdown_image::drafts news::markdown_image::drafts news::markdown_image::require_drafts->news::markdown_image::drafts acs_object_type acs_object_type (public) news::markdown_image::drafts->acs_object_type ad_conn ad_conn (public) news::markdown_image::drafts->ad_conn news::markdown_image::draft_path news::markdown_image::draft_path (private) news::markdown_image::drafts->news::markdown_image::draft_path news::markdown_image::enabled_p news::markdown_image::enabled_p (private) news::markdown_image::drafts->news::markdown_image::enabled_p news::markdown_image::mime_type news::markdown_image::mime_type (private) news::markdown_image::drafts->news::markdown_image::mime_type

Testcases:
No testcase defined.
Source code:
    set prefix [ad_conn package_url]markdown-image?image_id=
    if {$format ne "text/html" || [string first $prefix $content] == -1} {
        return {}
    }

    set drafts {}
    foreach tag [ns_parsehtml -onlytags -- $content] {
        lassign $tag element attributes
        if {![string equal -nocase $element img] || ![dict exists $attributes src]} continue
        set src [dict get $attributes src]
        if {[string first $prefix $src] != 0} continue
        # Responsive delivery adds query parameters after the stable image identity.
        set image_id [lindex [split [string range $src [string length $prefix] end] &] 0]
        if {![regexp {^[1-9][0-9]*$} $image_id] || [dict exists $drafts $image_id]} continue
        if {[acs_object_type $image_id] ne ""} continue

        set path [draft_path $image_id]
        set mime [mime_type $path]
        if {$mime eq "" || [ad_conn user_id] == 0
            || ![enabled_p]} {
            return -code error -errorcode {NEWS IMAGE UNAVAILABLE} "A pasted image is unavailable. Remove it or paste it again."
        }
        dict set drafts $image_id [list $path $mime]
    }
    return $drafts
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: