Semanticmediawiki: Image auto-caption from properties

Created on 26 Apr 2020  路  3Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

While uploading some files on smw.org and enrich a text with [[File:...]] file annotations, I was thinking that instead of copying the caption text from the file page to an individual file link it would make more sense that an image caption displays information from a stored property value on the related file page (given that a wiki has a policy which states uploaded content is required to be annotated in a structured fashion).

After some browsing in the MW repository, I found two hooks (ParserMakeImageParams and ImageBeforeProduceHTML) that would allow for such functionality to be added making auto-caption possible for images that store property values.

Adding that sort of functionality isn't really part of SMW core which means this has to go into an extra extension such as SemanticImageCaptionHandler or a better name?

Now, each user/wiki has different circumstances of how properties are defined and used, introducing a new IMAGE_CAPTION_SCHEMA schema should help define rules for those circumstances such as:

{
    "type": "IMAGE_CAPTION_SCHEMA",
    "caption_rules": {
        "default_rule": {
            "max_length": 200,
            "allow_caption_override": false,
            "add_figures_reference": true,
            "use_property": "MyLocal_X_CaptionProperty"
        },
        "z_caption_rule": {
            "if": {
                "category": "z_category"
            },
            "then": {
                "add_figures_reference": false,
                "use_property": "MyLocal_Z_CaptionProperty",
                "max_length": 200,
                "allow_caption_override": true
            }
        }
    },
    "tags": [
        "image",
        "image caption"
    ]
}
  • allow_caption_override to allow overriding an existing caption used as part of the [[File: ...]] declaration
  • add_figures_reference auto add a Figures ... reference as part of the caption (https://rmit.libguides.com/harvardvisual/figures)
question

Most helpful comment

All 3 comments

I think a new extension just to add such a functionality is too work (obviously, I have no idea of the development work, but I am thinking about more extension releases to Karsten, composer incompatibilities, new issues repository, etc.). I wonder if this could not be present in SemanticCite. add_figures_reference, "image caption", etc. are closely related to formal texts, and so, citation resources. Of course, you can use captions on whatever text style you want, but still I have a feeling that aggregating such a functionality would be good in SemanticCite.

Now serving on sandbox.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osnard picture osnard  路  3Comments

djoris picture djoris  路  4Comments

akuckartz picture akuckartz  路  3Comments

SteveRMann picture SteveRMann  路  4Comments

JeroenDeDauw picture JeroenDeDauw  路  3Comments