Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not fetch image of some link like ChatGPT or TikTok #58

Open
harrynguyenangle opened this issue Jan 22, 2024 · 1 comment
Open

Can not fetch image of some link like ChatGPT or TikTok #58

harrynguyenangle opened this issue Jan 22, 2024 · 1 comment

Comments

@harrynguyenangle
Copy link

harrynguyenangle commented Jan 22, 2024

There's some issue that the data from LinkPreview can not fetch image from link like ChatGPT or TikTok, but works well some common link like Google, YouTube, Drive, StackOverFlow, etc

LinkPreview(
              enableAnimation: true,
              onPreviewDataFetched: (data) => setPreviewDataURL(data),
              previewData: previewURLdata, // Pass the preview data from the state
              text: urlString,
              width: widget.width,
              previewBuilder: (p0, p1) {
                return Column(
                  children: [
                    // IMAGE
                    if (p1.image != null)
                      Container(
                          height: 100,
                          width: widget.width + 4,
                          margin: const EdgeInsets.fromLTRB(1, 1, 1, 10),
                          child: ClipRRect(
                            borderRadius: const BorderRadius.only(
                              topLeft: Radius.circular(15),
                              topRight: Radius.circular(15),
                            ),
                            child: Image.network(p1.image!.url, fit: BoxFit.cover),
                          )),

                    // TITLE
                    if (p1.title != null)
                      Container(
                          margin: const EdgeInsets.only(left: 10, right: 10, top: 5),
                          child: Text(p1.title!,
                              maxLines: 3, style: TextStyle(fontWeight: FontWeight.w600, color: widget.titleColor))),

                    // URL
                    if (p1.link != null)
                      Container(
                        margin: const EdgeInsets.only(left: 10, right: 10, bottom: 8),
                        child: Text(
                          p1.link!,
                          overflow: TextOverflow.ellipsis,
                          maxLines: 1,
                          style: TextStyle(
                            color: widget.urlColor,
                          ),
                        ),
                      )
                  ],
                );
              }),```
@demchenkoalex
Copy link
Member

Yeah it won't work for everything, sometimes frontend is blocked from reading link metadata. If you want a robust solution that will work for everything, you need a backend solution, something like https://www.linkpreview.net or similar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants