-1

How would I add functions to images? I host a photography site, in which I'd like to add options to favorite an image or attach it to a product for ordering.

Is there a hook or something that I can tap into to add a few buttons to each image on hover?

Which Wordpress functions or files handles image management?

Ideally, I would also need a function that would limit it to specific post types (photo album) so that these functions are not being added to non relevant images.

I have some familiarity with php, but I haven't done much playing with hooks or anything so the more guidance I could get the better. I often get stuck in customizing trying to interpret the code in existing themes/ plugins to really know how to modify anything.

I am not asking for help in creating the functions: just to be pointed in the right direction as the hooks I could tap into to do what I've gotta do. There are so many, that I'm not sure where to look.

2
  • Have you tried, read or put any effort in finding a solution yourself?
    – flomei
    Dec 11, 2015 at 9:07
  • I have not worked on the function, and I am not looking for help on the function, I simply need help in identifying the hook that relates to image display. There are so many, and many I don't really understand, I'm just trying to save some time in that regard. The solution will be something along the lines of For each image in album type= photo album, run function 'attach favorite' If I can just figure out the script/ hook that is responsible for image display, i'll figure out the rest.
    – Jon C
    Dec 11, 2015 at 19:55

1 Answer 1

0

If you want to append HTML to images, you want to look inside the template files. Search for something like the_post_thumbnail function, and add your HTML right after the closing </a> tag (if there is one). You'd then need to style it with CSS so that it's only visible upon hovering the image.

For example, in twentyfifteen theme (located inside /wp-content/twentyfifteen in the file system), content.php has a function (twentyfifteen_post_thumbnail) which is defined in inc/template-tags.php, and it's used to display images on 'single post' pages as well as 'post list' pages.

If you're after giving users an ability for album images to be shared (on Pinterest, etc.), it would be much easier to find a plugin that does this - there are quite a few, and you may just find one that has the effect you're looking for.

2
  • ok, so what I am getting from your answer, is that each theme may have a different function/ hook needed to affect image files. If that is true, that is what I was afraid of. The developer of my theme made such complicated code, that it is hard to follow and customize. I am mainly looking to build a function that would allow a user to pick a favorite image, and then attach that image to a product i'll make in woo commerce. So the end Woocommerce add on, if I can figure that out, would find all images a user has marked as favorites and give them a possibility to associate a product w/ it
    – Jon C
    Dec 11, 2015 at 22:09
  • Well, each theme might have its own functions and hooks on toop of the ones WordPress provides; but it may not necessarily be the case. I just pointed out the easiest path to what you want to achieve, given your task description. With what you just commented it looks like you'd need to create a custom plugin to enable what you want to do. Upwork is a good place to look for contractors if you can't do it by yourself. Dec 12, 2015 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.