• Resolved peachperfectweddings

    (@peachperfectweddings)


    We have a lot of images that we are not using on the website. We need to tidy them up (delete). I tried different plugins, but none of them can detect all different ways how pictures are added to a page. For example some gallery plugins.

    Now I just want to go over all pages and add them manually. Hopefully I can still automate parts of the process.
    I can get a list of image URLs from Spider SEO.

    Is there a way I can add a Tag in PHP?
    Is there some MLA function to do it?
    I could iterate using some PHP over all images in our library, check if the file name is in the list I got from Spider and add a Tag like “used on website”

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for describing your application and for your question. This kind of “where-used” task is exactly what led me to start developing the MLA plugin in the first place!

    You can use MLA’s where-used features to get a good start on your work. Navigate to the Settings/Media Library Assistant General tab and scroll down to the “Where-used Reporting” section. Activate whatever combination of the four categories you want, scroll to the bottom and click “Save Changes” to record the new settings. Then, go back to the Media/Assistant submenu to view the analysis. You may have to pull down the Screen Options and check the boxes next to the categories you want in order to make them visible.

    MLA’s features include analysis of the [gallery] and [mla_gallery] shortcodes, but it does not support other gallery plugins just because of the work required to test and understand them. MLA does provide many actions and filters you could use to add your own PHP code to operations like Quick/Bulk editing or IPTC/EXIF/Custom Field mapping. You can also look at MLA’s code to get a better idea of how the analysis is done.

    I hope that gives you some ideas on how to proceed. I will leave this topic unresolved in case you have more specific questions about how MLA can help achieve your goal. Any further details you can provide would be useful. Thanks for your interest in the plugin.

    Thread Starter peachperfectweddings

    (@peachperfectweddings)

    Thanks for your prompt reply!

    “it does not support other gallery plugins just because of the work required to test and understand them”
    This is exactly my issue. After some research, I believe there is no plugin in the world, that can check. Our theme alone uses like 5 different ways to insert images. And we also have another gallery plugin.

    So I think your method will only reveal a portion of used images, but I guess it is a good start. …also you just opened a whole new world to me with all these options… I didn’t look into settings so far!

    So the only safe way I found, is to go to each page, use some tools like Spider SEO to get list of all used images, then check if they are in the library, tag them with “USED-DON’T DELETE” and delete all others… hope to do it with some PHP, like:

    1. get list of used image file names from Spider SEO

    2. iterate through all posts (image is also a post…)
    https://codex.www.ads-software.com/Class_Reference/WP_Query

    3. check against list from 1

    4. update some meta (Caption, description… custom field?) with “USED – DON’T DELETE”
    https://codex.www.ads-software.com/Function_Reference/update_post_meta

    5. filter in Assistant and delete those without the tag “USED – DON’T DELETE”

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the additional information. You wrote “So I think your method will only reveal a portion of used images, but I guess it is a good start.” I think that’s exactly right; a good start. MLA doesn’t check for items used in sidebar widgets, for example. If you know your theme and your application you can do a better job.

    MLA examines the post_content of each post and page but it doesn’t actually generate the final result to look for theme-related uses. Using an SEO tool is an interesting alternative I haven’t explored.

    The 5-step process you outlined is reasonable and might be sufficient for your application. It does, however, fail in use cases that depend on user input to dynamically generate a gallery. For example, many MLA applications use some sort of UI to let the user pick one or more terms from a custom taxonomy and then generate a gallery of the items matching the selected term(s). I haven’t been able to figure out a way to automate that process.

    Assigning a “USED” value to a standard field like Caption, a taxonomy term or a custom field can be done by defining an IPTC/EXIF mapping rule and then using the hooks provided during the mapping process to evaluate each item as it’s mapped. There are some examples of this process in the MLA “Example Plugins”, which you can browse by navigating to the Settings/Media Library Assistant Documentation tab and then clicking Example Plugins. In fact, your project might be an interesting candidate for yet another example plugin.

    Steps 4 and 5 are well supported by MLA. You can sort and/or filter the Media/Assistant submenu table and then delete the items you want easily.

    I’ll leave this topic open for now. Let me know how I can help you pursue your project.

    Plugin Author David Lingren

    (@dglingren)

    Thank you for your donation in support of our fair trade work. Donations, reviews and positive feedback are great motivators to keep working on the plugin and supporting its users.

    I hope the above suggestions give you a start on your analysis and site cleanup. I am marking this topic resolved, but please update it if there is anything else I can do to help you get the most out of MLA.

    Thread Starter peachperfectweddings

    (@peachperfectweddings)

    Hi David. Since I already had like 80% of pictures under Categories or Tags, I just went over all remaining and added them manually. But thank you anyway for the above info and in general for developing MLA. It is a great plugin which is a core part of our website.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for you update and for the kind words. Good luck with your application and please start a new topic if there’s anything else I can help with.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding a Tag to all pictures used on ALL pages (via PHP?)’ is closed to new replies.