Skip to main content
added 131 characters in body
Source Link
Pwner
  • 185
  • 1
  • 6

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 isbecomes invisible. I have a feeling that Stack Exchange only supports a limited set of HTML attributes and width and style are not visibleamong them. 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
        ]
    }
];

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
        ]
    }
];

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 becomes invisible. I have a feeling that Stack Exchange only supports a limited set of HTML attributes and width and style are not among them. 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
        ]
    }
];
Source Link
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
        ]
    }
];