Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Interferon Posted July 31, 2022 Posted July 31, 2022 (edited) I'm trying to create a visual stream of activity for my website and desktop application, incorporating gallery images, videobox videos, and blog entries into a single stream sorted by date. I have it all working except the blog entry header images. This is important, because the blog header image is what I plan to show in the background of the tiles for blog entries, making the whole system cohesive. I'd prefer not to post any screenshots of my application here, but it looks good and it's a really nice visual way to just take in all recent activity at a glance. Edited July 31, 2022 by Interferon
Marc Posted August 1, 2022 Posted August 1, 2022 I have moved this topic to our developer forums, where it is better placed to be assisted with. We would not be able to assist with development under standard support
Interferon Posted August 3, 2022 Author Posted August 3, 2022 This code does it, but does not properly parse the CSS attribute, so if any other style elements are added it will fail: <?php function getBlogHeaderImage($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $page = curl_exec($ch); curl_close($ch); // Remove some HTML elements $dom = new DOMDocument(); $dom->loadHTML($page); $classname="cBlogEntry_withPhoto"; $finder = new DomXPath($dom); $items = $finder->query("//*[contains(@class, '$classname')]"); if ($items->length == 0) return ""; $style = $items[0]->getAttribute("style"); $style = str_replace('background-image: url("', '', $style); $style = str_replace('")', '', $style); return $style; } $url = 'https://linustechtips.com/blogs/entry/2114-you-dont-want-to-use-a-linux-converted-chromebook/'; echo(getBlogHeaderImage($url)); ?> SeNioR- 1
Recommended Posts