How to return the generated image by phpThumb and not the original one with code appended? - wordpress

I'm generating images through phpThumb on my Wordpress based website using Magic Fields 2 but I'm having problems posting those images to We Heart It and other websites since they don't recognize it as an image due to all the code appended.
Therefore I was wondering if there's a way to make phpThumb return the actual generated image thumbnail link instead of the original link with all the code appended like:
http://www.mywebsite.com/wp-content/themes/basetheme/phpThumb/phpThumb.php?src=http://www.mywebsite.com/wp-content/files_mf/1331856830IMG_0286.jpg&w=364&h=200&zc=1&q=95
Is there any way to achieve this?

http://ailoo.net/2008/07/wordpress-plugin-autothumb-phpthumb/ <-- I'm using this plugin for the same! :)

Related

Wordpress inline SVG won't display, does display in visual editor

I'm trying to insert an inline SVG of a US map in a Wordpress post. A test page where it's been inserted into the post as an HTML block with some light CSS is here: http://thepostrider.com/test-post/
When I edit it in the Gutenberg editor I can see the SVG and all, but on preview/publish nothing. It's clearly there in the code if you inspect the element on that published page but cannot for the life of me get it to manifest in the post. Historically I've gotten around this by building out custom pages and inserting SVGs into php files, but I do need to start building out this kind of thing in individual posts now too; so I would love some advice.
Take a closer look at the HTML source:
<g id="g5">
<path id="HI" data-info="<div>State: Hawaii</div><div>Capital: Honolulu</div>”
fill=”#D3D3D3″ d=”M407.1,619.3l1.9-3.6l2.3-0.3l0.3,0.8l-2.1,3.1H407.1z M417.3,615.6l6.1,2.6l2.1-0.3l1.6-3.9
l-0.6-3.4l-4.2-0.5l-4,1.8L417.3,615.6z M448,625.6l3.7,5.5l2.4-0.3l1.1-0.5l1.5,1.3l3.7-0.2l1-1.5l-2.9-1.8l-1.9-3.7l-2.1-3.6
l-5.8,2.9L448,625.6z M468.2,634.5l1.3-1.9l4.7,1l0.6-0.5l6.1,0.6l-0.3,1.3l-2.6,1.5l-4.4-0.3L468.2,634.5z M473.5,639.7l1.9,3.9
l3.1-1.1l0.3-1.6l-1.6-2.1l-3.7-0.3V639.7z M480.5,638.5l2.3-2.9l4.7,2.4l4.4,1.1l4.4,2.7v1.9l-3.6,1.8l-4.8,1l-2.4-1.5 L480.5,638.5z
M497.1,654.1l1.6-1.3l3.4,1.6l7.6,3.6l3.4,2.1l1.6,2.4l1.9,4.4l4,2.6l-0.3,1.3l-3.9,3.2l-4.2,1.5l-1.5-0.6l-3.1,1.8
l-2.4,3.2l-2.3,2.9l-1.8-0.2l-3.6-2.6l-0.3-4.5l0.6-2.4l-1.6-5.7l-2.1-1.8l-0.2-2.6l2.3-1l2.1-3.1l0.5-1l-1.6-1.8L497.1,654.1z”/>
... etc ...
It looks to me like Wordpress has converted all your quotation marks into smart quotes (” and ″). That's not going to help.
You would be better off uploading the SVG file as an image and inserting it that way. (You may need to install additional plugins to do this, as Wordpress won't allow SVG uploads in its default state.)
By the way, the next time you ask a question about code or markup, please create a minimal reproducible example and insert it directly into your question. Links to code on other sites are liable to break, making your question useless for others. Thanks.

How to add an HTML class to all image attachments on posts in Wordpress -- except homepage

Sorry for the length, my problem is very simple, but specific.
I'm building a wordpress site that automatically imports image galleries from a Tumblr account, then styles and displays them. The backend is finished, and all that I need now is have all images in posts be displayed as thumbnail sized links. They are not behaving well with the importer (I've tried 6), so I have to edit the HTML display (rather than the images as they are uploaded).
I have decided to do this by applying class="attachment-thumbnail size-thumbnail" on all images on the site (in HTML). I have tested this and they will open the proper gallery in a lightbox as necessary so long as they belong to those two classes.
I have a two part problem.
I do not know PHP past basic syntax, and while I can intuit most of what is happening I don't trust myself to edit Wordpress source code without understanding exactly what I am breaking.
From other answers I've learned that I should most likely edit the wp_insert_attachment() function in post.php under wp_includes/. I have found the function, but don't really know where to go from there, as it does not appear to be specific to image attachments. I don't want to throw any errors by assinging image classes to non-image attachments. How do I add those two classes (attachment-thumbnail and size-thumbnail) to all post images (and only images)?
There is a single exception to this rule. I want a large image on the homepage, and have it not be a link.
It seems like the way to handle this would be to allow page attachments to be handled normally, while attachments that are both images and attached to posts should trigger this:
if [attachment is an image AND is on a post, not a page]:
<img src="https://whatever">
becomes
<img src="https://whatever" class="attachment-thumbnail size-thumbnail">
tl; dnr: ^^ that's all I need to happen, in PHP, in the right file, in Wordpress ^^
Thanks!
So likely you will want to do it via php but instead you could do it with javascript ie jQuery:
<script>
$(function() {
$("body img").addClass("attachment-thumbnail size-thumbnail");
});
</script>
Put that on any page or site header and it will add the class to all images. You can modify the search filter to suit.
You might need to re-call your lightbox initialization code too, or put this before it gets called initially.

How to replace all attachment links in post with media file link

I've been breaking my head over this for a few days but I yet have to find a proper solution. I'm working on a Wordpress site, where all images inside posts are linking to the corresponding attachment pages. I want to use a lightbox but obviously this would require changing all the links back to the media files directly (e.g. xyz.jpg).
The site has a significant number of posts and images so it would be impossible to do this manually.
Does anyone know of a plugin or other solution that would simply replace - in bulk - all of the image links to link to the media file, instead of the attachment page?
Here is one answer that, although jQuery-based, did the trick, and is much quicker than and safer than a PHP-script to go through the whole DB. The drawback is that it will link to the resized image url instead of the full image url. There's probably a way to catch that with jQuery as well, but this was enough for my needs.
$("article.my-post-class a img").each( function(){
var src = $(this).attr("src");
$(this).parent("a").attr("href", src);
});

Magento catalog image change on hover

On the catalog/category page I would like images change when hover. Like clubmonaco.com I know how to do it on html/css but no idea on magento. Any help?
You could modify files in this directory:
app/design/frontend/base/default/template/catalog/product
for example (list/ and list.phtml)
or your template for example:
app/design/frontend/default/yourtemplate/template/directory with product files
CSS files you can find in:
skin/frontend/
You should also think, where the second image is stored. You can use "CSS-Sprites" for this case - a single image file, that contains both photos. The disadvantage is, that you have to customize every page, where magento shows product images.
Alternatively you have to define exact orders. First image is the front view, second image is always the back view.
The programming part is not really difficult. Look at
app/design/frontend/base/default/template/catalog/product/list.phtml
for the Catalog view. Path can vary, if you have a custom template. In the Magento backend there is a feature to show up the real path (system->configuration->development tools).
You can write your Javascript directly into the list.phtml. Magento also writes JS-code directly in the .phtml files. Of course it's not very pretty, but Magento is so complex; if other people work with the shop system, it will be easier to find.
Keep in mind, that the list.phtml contains two layouts: Grid and List View. Just if you do a change and wonder, why you can't see a change in the frontend ;-)

Wordpress images as subposts

Is it possible to have images in a certain post to be showed as subposts? What I mean is a structure like this:
post - http://www.blog.com/some-post
I want all images in that post(10) to be shown like this when clicked
www.blog.com/some-post/image-1
www.blog.com/some-post/image-2
...
www.blog.com/some-post/image-10
is this possible?
There are two Ways:
You can Create a page with Name: "some-post" and subpages for Images: "image-1", "image-2" and so on, and link them to your images.
Better and easier way, read this: http://codex.wordpress.org/Using_Image_and_File_Attachments#Permalinks
Here the Example of the easier way:
If you Upload an image image3.png and insert it in your Post sample-post, than you can see the image under http://domain.tld/link-to-your-sample-post/image3 just without the ending .png or .jpg or .gif or anything else, this is the easiest way..

Resources