Skip to main content
1 of 3
Pwner
  • 185
  • 1
  • 6

How to set the width of an image in the body of a question?

I used the questions/{ids}/edit to add a hyperlinked image at the end of a question. It works if I use the default dimensions of the image. However, if I specify the width using width="320" or style="width:320px", the image is not visible. Below is an Objective-C (iOS) example of how specifying a width causes the image to not show up.

[self.httpEditQuestion
    requestWithUrl:[NSURL URLWithString:[NSString stringWithFormat:
        @"%@questions/%@/edit",
        API_BASE_URL,
        self.currentQuestion.identifier
    ]]
    post:@{
        @"key": APP_KEY,
        @"access_token": self.accessToken,
        @"id": self.currentQuestion.identifier,
        @"preview": @"false", // TODO
        @"site": self.currentQuestion.siteIdentifier,
        @"tags": [self implode:self.currentQuestion.hashTags],
        @"title": self.currentQuestion.name,
        @"body": [NSString stringWithFormat:
            @"%@ <p><a href=\"%@\"><img width=\"320\" src=\"%@\" /></a></p>",
            self.currentQuestion.body,
            self.currentUrl,
            self.currentThumbnail
        ]
    }
];
Pwner
  • 185
  • 1
  • 6