Skip to content

[DomCrawler] Support images like links #12429

@valeriangalliat

Description

@valeriangalliat

I once needed to find an image and compute its full URI like Symfony\Component\DomCrawler\Link::getUri is doing, but unfortunately an img element is not accepted by the Link::setNode (thus calling Crawler::link on an img element is failing.

I have extended the Crawler class to provide an image function just like the link function, but returning an Image object (a new class extending Link, but overriding setNode to accept img elements), so I can use getUri to compute a full image src URI.

I was wondering if this feature may interest other people, and maybe be merged in this repo?

If so, do you think the image method with its associated Image class is a good solution, or it's better to just allow img elements in Link::setNode?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions