determineImageSource for images without width and height attributes
bejean opened this issue · comments
Images without weight and height attributes are ignored by determineImageSource method.
I think images without these attributes can be considered as images with width > 50 and height > 50
Futhermore width=50 and height = 50 are also ignored by the test
if (height > 50)
weight += 20;
else if (height < 50)
weight -= 20;
In my opinion, we should use :
int weight = 0;
int height = 0;
int width = 0;
try {
height = Integer.parseInt(e.attr("height"));
} catch (Exception ex) {}
if (height == 0 || height >= 50)
weight += 20;
else if (height < 50)
weight -= 20;
try {
width = Integer.parseInt(e.attr("width"));
} catch (Exception ex) {}
if (width == 0 || width >= 50)
weight += 20;
else if (width < 50)
weight -= 20;
Hi, thanks for the suggestion. Did you run the tests and do they pass?
Yes, I am using this update.
I am also adding a getImageUrlBestMatch() method in JResult object.
The purpose is to get an image url only if the image comes from bestMatchElement.
getImageUrl() still returns image coming from bestMatchElement or metada.
I will make a pull request tonight or tomorrow.
This would be nice
Pull request made just for width=50 and height = 50 are also ignored by the test
for getImageUrlBestMatch() method, it will be made in a next pull request