mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
Enabled fetching .ico
dimension size via probe-image-size
refs https://github.com/nodeca/probe-image-size/blob/master/CHANGELOG.md#600---2020-11-04 - `probe-image-size` v6 now supports `.ico` files so we can allow probing of dimensions via this library rather than falling back to downloading the entire image via `image-size` - also updates a test because .ico files no longer use the internal request lib, which simplifies things a little bit
This commit is contained in:
parent
5687fb9213
commit
8a7c7f08e9
2 changed files with 8 additions and 11 deletions
|
@ -14,7 +14,7 @@ const messages = {
|
|||
|
||||
// these are formats supported by image-size but not probe-image-size
|
||||
const FETCH_ONLY_FORMATS = [
|
||||
'cur', 'icns', 'ico', 'dds'
|
||||
'cur', 'icns', 'dds'
|
||||
];
|
||||
|
||||
class ImageSize {
|
||||
|
|
|
@ -127,7 +127,10 @@ describe('lib/image: image size', function () {
|
|||
width: 64
|
||||
};
|
||||
|
||||
const requestMock = nock('https://super-website.com').get('/random-path').reply(404);
|
||||
const requestMock = nock('https://super-website.com')
|
||||
.get('/media/icon.ico')
|
||||
.replyWithFile(200, path.join(__dirname, '../../../../utils/fixtures/images/favicon_multi_sizes.ico'));
|
||||
const requestMockNotFound = nock('https://super-website.com').get('/random-path').reply(404);
|
||||
|
||||
const imageSize = new ImageSize({config: {
|
||||
get: () => {}
|
||||
|
@ -135,17 +138,11 @@ describe('lib/image: image size', function () {
|
|||
isLocalImage: () => false
|
||||
}, validator: {
|
||||
isURL: () => true
|
||||
}, urlUtils: {}, request: (requestUrl) => {
|
||||
if (requestUrl === url) {
|
||||
return Promise.resolve({
|
||||
body: fs.readFileSync(path.join(__dirname, '../../../../utils/fixtures/images/favicon_multi_sizes.ico'))
|
||||
});
|
||||
}
|
||||
return Promise.reject();
|
||||
}});
|
||||
}, urlUtils: {}, request: {}});
|
||||
|
||||
imageSize.getImageSizeFromUrl(url).then(function (res) {
|
||||
requestMock.isDone().should.be.false();
|
||||
requestMockNotFound.isDone().should.be.false();
|
||||
requestMock.isDone().should.be.true();
|
||||
should.exist(res);
|
||||
res.width.should.be.equal(expectedImageObject.width);
|
||||
res.height.should.be.equal(expectedImageObject.height);
|
||||
|
|
Loading…
Add table
Reference in a new issue