Wordpress - Dynamically Process Image - php

I have images uploaded in the media library in WordPress. I would like to show the images with text composited on top of them using PHP's GD or something similar.
If this were just a plain old PHP site, I could create a URL with a search parameter for the text and center it over my image with GD and serve it up. In WordPress, I am a little unclear how to accomplish this. I am not sure if it fits well into the concepts of Posts and Pages.
I can perform the programming myself. I am just looking for some pointers on how to get started.
Thanks,
Carl

You can do that in WordPress, too. It's mostly just a plain old PHP site. For example, you could create a PHP file that creates the composite given the text and the image and use it like: <img src="/composite.php?image=...&text=...">.
Maybe all of the images are on a particular page or post type. Then you could create a custom page or post-type template that parses the $post->post_content for the images, does the compositing, and alters the image tags to point to the new composited images.
Or, more generally in that vein, create a filter for the_content that does that for all posts.
You might be able to hook into the WordPress upload system. As images are uploaded, you could create the composite. The wp_handle_upload filter might work for that.
Or you could even create a WordPress cron job that scans the media uploads for new entries and creates the composites then.

Related

Placing Text-Container over Image using php Wordpress

I want to program a plugin that sets a Text-Container over a Image in Wordpress. Im using the Divi Themen. My idea: I need to find where Images are rendered and add my container where I place my text with something like "get_meta_data()". The needed field are already in the media library. I just need to find how to create the conainer and place it over every image where my text exists. Any Ideas/Tipps?

Wordpress: make a post's video URL accessible from the loop

I'm looking for solution to a particular situation. In my theme each post is on a single page (single.php). Single page has a slider inside of the loop that is populated with attachment images. In that slider, I need to add some videos that are hosted on YouTube.
What I think I need is to write a plugin that allows to add YouTube URLs to a post in UI input fields in post editing window. These links would be then accessed using post id from single.php, so that I could loop through them, using foreach and render them as as html5 video.
I need a general advice on how this can be done. I've got a working slider that needs to host these videos along attachment images, but using attachment video does not work and it doesn't seem to be a viable solution (it's bandwidth intensive).
Any help is appreciated.
Thanks
I've sorted this out using a simpler approach, namely, I've used shortcodes to wrap content that's in the slider. It worked fine and saved plenty of time; it's more intuitive in comparison to using image attachments for creating the content, too.

Drupal 7:replace original image with ImageStyles generated image

I'm using regular imagefields on various content types in a Drupal 7 social website (and also on the user profile pictures via http://drupal.org/project/imagecache_profiles). For cropping I'm using http://drupal.org/project/imagecrop as an image style effect.
I would like to replace the original image with the one generated from the imagecrop style. How do you replace the original image from a user (the one that gets used for subsequent image styles when you say call it in views) with one that is created from an image style effect?
I'm not sure the best way to approach this problem, which is why I posted question.
To make sure I'm being clear -
A User uploads a large image (say 2,000 pixels by 1300 pixels) via a regular imagefield.
Using image styles, I perform some effects (specifically javascript crop, but this could be generic) and then replace the original image with the one generated from the image style.
All additional image styles (different sizes etc) use the new original images and are derived from it.
I think this can be done easily using a custom module and they must have used something like the image editor project - See drupal.org/project/imageeditor, just not sure what hooks to use or how to jump in on this. Any advice, tips or direction would be great.
Check module - Original image with style
I believe you can address your problem by making changes under the display settings for your field:
/admin/structure/types/manage/[your content type machine name here]/display

How can I generate a thumbnail of a web page for a facebook post?

My app is posting to users' Facebook walls, and linking to a page they have created. The page is in html. I'd like to be able to put a thumbnail of the page as the image on the wall post. I'm not sure whether this is possible or not. Anyone have any ideas?
If it helps, the page itself is stored as a series of 'elements'... for each one, I know the size and position of the element, and the content (which may be text or an image). So I can pull all that in from the database.
I guess it would be sufficient to create a thumbnail using php at the point when the user clicks 'Publish This to my wall', if that's easier than doing it on the fly - I can save the image and then link to it.
Any ideas?
I create thumbnails for my site using CutyCapt, which works very well indeed on both Windows and Linux. You can use exec to invoke this from php.
There are also web services that allow you a quota of free thumbnail snapshots, that are easy to integrate into your website. e.g.
http://www.websnapr.com/
or
http://webthumb.bluga.net/home
I figured out how to do this. I used the PHP gd library, which allows you to create a base image and then add images and text. Works pretty well.

Imagecache with amfphp and flash multiple issues

I inherited a project with drupal and flash, and I'm pretty noobish on the topic so please don't bash me.
What I'm stuck at is that I need to create multiple thumbnails for each uploaded image (5 version to be precise with different settings eg. 150w, 250w,..) I created the presets but I can't seem to understand how imagecache works: it looks like the module builds the thumbnails only after I firs see the images, problem is that after I create the node I'm greeted with this view:
as you may notice some of the fields can have multiple images.
If I'm correct in my assumption that imagecache only builds thumb when you first access the node why I can't see the images but only the icons? Alternatively is it possible to force imagecache to create the different sizes as soon as the images are uploaded?
If not how does imagecache works?
Thanks
Imagecache only creates the thumbnails when they are requested the first time, but that should not result in this problem. Check if in your content type (under "display fields") the filefield containing the images is set to display an imagecache preset, not something like "Generic Files".

Categories