Jump to content

bdbdbd

Members
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • Location
    Germany

bdbdbd's Achievements

Newbie

Newbie (2/6)

2

Reputation

  1. hi @nbcommunication You are absolutely right! but I don't have the skills and knowledge of processWire and php to do it that way. 🥲 I'm not super happy with my solution, but it reduces the amount of data to be transferred to a good level. it is of course a quick and dirty implementation based on my skills. 🙄 since I don't want to display the images on the page in full resolution but only link to instagram it makes sense not to have to load everything and just squeeze it small in the display. i read that in the "old" instagram api there was the possibility to request different image versions. this would actually be the perfect solution for the topic. this should potentially interest many users of the InstagramBasicDisplayAPI. Maybe there will be an update from Instagram? regardless, your module is a huge relief, 1000 thanks for that!
  2. hi @nbcommunication, thanks for your quick response. yes, that's what i thought, and i was hoping that there would be an easy way to reduce the image size with processwire. i'm doing it now like this. I reduce the imagesize and do some croping to squared images via php, then save it to the temp-folder and link to this image. $instagram = $modules->get('InstagramBasicDisplayApi'); // Get 10 images $images = $instagram->getImages(10); $counter = ''; echo '<div class="start_instagram uk-grid-column-small uk-grid-row-small uk-child-width-1-2@s uk-child-width-1-5@m" uk-grid>'; foreach ($images as $image) { $counter = $counter + 1; $instagramImageUrl = $image->src; $imageData = file_get_contents($instagramImageUrl); $fileName = 'instaBild' . $counter . '.jpg'; $filePath = $config->paths->assets . "instaTemp/" . $fileName; // Verkleinere das Bild auf eine maximale Breite von 300px $maxWidth = 300; list($width, $height) = getimagesizefromstring($imageData); $aspectRatio = $width / $height; $newWidth = min($maxWidth, $width); $newHeight = $newWidth / $aspectRatio; // Erstelle ein leeres quadratisches Bild $imageResized = imagecreatetruecolor($maxWidth, $maxWidth); $imageSource = imagecreatefromstring($imageData); // Berechne die Position für das Cropping (zentriert) $cropX = 0; $cropY = 0; if ($width > $height) { // Querformat, seitlich beschnitten $cropX = ($width - $height) / 2; } elseif ($width < $height) { // Hochformat, oben und unten beschnitten $cropY = ($height - $width) / 2; } // Führe das Cropping durch imagecopyresampled($imageResized, $imageSource, 0, 0, $cropX, $cropY, $maxWidth, $maxWidth, $width - (2 * $cropX), $height - (2 * $cropY)); // Speichere das verkleinerte und beschnittene Bild imagejpeg($imageResized, $filePath); imagedestroy($imageResized); imagedestroy($imageSource); // echo $fileName . " auf " . $filePath . " gespeichert.<br>"; $tempPath = "/site/assets/instaTemp/" . $fileName; $altDesc = $image->alt; echo "<div> <a href='". $image->href ."' target='insta'> <img src='" . $tempPath . "' alt='" . $altDesc . "' title='". $altDesc ."'> </a> </div>"; } echo '</div>'; ?> i think this solution is OK, since i have proCache running and so it doesn't regenerate on every page load, or am i wrong? there are 10 images loaded which are now about 160kb in size as compared to the 3mb for the originals. suggestions for improvements are still welcome, i wanted to make sure i hadn't overlooked any major option.
  3. Hi all, I am new to processwire, it is my first project with it. I use this module and it works quite well. Is it possible to load smaller image versions instead of the orginal from instagram. I actually only need about 300 x 300px for a gallery that will then be linked to instagram. At the moment the large originals are loaded which are unnecessarily much data. I tried to download the images first, which works fine, and then i want to resize them via processwire to show the smaller versions instead of the originals. unfortunately this doesn't work as expected with $filepath->size(300,300) . what am i doing wrong? <?php $instagram = $modules->get('InstagramBasicDisplayApi'); // Get 10 images $images = $instagram->getImages(10); $counter = ''; foreach ($images as $image) { $counter = $counter + 1; $instagramImageUrl = $image->src; $imageData = file_get_contents($instagramImageUrl); $filename = 'instaBild' . $counter . '.jpg'; $filePath = $config->paths->assets . "instaTemp/" . $filename; file_put_contents($filePath, $imageData); $thumb = $filePath->size(300, 300); echo $thumb->url; } ?> this is certainly not very elegant and above all does not work 😞 i get this error message. Fatal Error: Uncaught Error: Call to a member function size() on string in site/templates/m_instagram.php:104 how can i process and output the images that are downloaded in the "instaTemp" folder? or is there a simple way to define the output size in the InstagramBasicDisplayApi module? i'm sure it is possible but my skills in php and processWire are very limited! thanks a lot in advance
×
×
  • Create New...