iwf
    Preparing search index...

    Class CommonsMediaSnak

    Class for the CommonsMediaSnak.

    Most used property of this type is P18 (image).

    Hierarchy (View Summary)

    • Snak
      • CommonsMediaSnak
    Index
    • Parameters

      • snak: {
            datatype?: "commonsMedia";
            datavalue?: { type: "string"; value: string };
            hash?: string;
            property: string;
            snaktype: "value" | "somevalue" | "novalue";
        }

        The snak for this class in JSON format.

      Returns CommonsMediaSnak

      If the input does not match this datatype's Wikidata schema.

      const snak = new CommonsMediaSnak(json);
      
    datatype: string = dataType
    fileName: string | null

    The file name as used in the Wiki Commons URL

    hash: string | undefined
    property: `P${number}`
    snaktype: "value" | "somevalue" | "novalue"
    • get hasValue(): boolean

      Checks if the snak has a value.

      Returns boolean

      True if the snak has a value.

    • Gets the link to the image. Uses the Special:Redirect function of Wiki Commons to find the right URL.

      Returns string

      The link to the image.

    • get internalID(): string

      Creates a unique ID for the Snak.

      Returns string

      The ID.

    • Returns {
          datatype?: "commonsMedia";
          datavalue?: { type: "string"; value: string };
          hash?: string;
          property: string;
          snaktype: "value" | "somevalue" | "novalue";
      }

      The snak as JSON.

      const json = CommonsSnak.toJSON();
      
    • Creates a snak from a property and a file name.

      Parameters

      • property: `P${number}`

        The property of the snak in 'P-form'.

      • fileName: string

        The file name.

      Returns CommonsMediaSnak

      A snak with the given properties.

      const snak = CommonsMediaSnak.fromFileName('P18', 'Example.jpg');