Get link to image on pixabay or license

Created on 8 November 2023, 8 months ago
Updated 15 March 2024, 4 months ago

Very useful module, thank you.

Is there a way to get some metadata along with the image? For example for a field with the media type linking to the "original" image at the pixabay site, or some license information?

✨ Feature request
Status

Fixed

Version

3.0

Component

Code

Created by

🇩🇰Denmark lennart

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @lennart
  • 🇸🇮Slovenia slogar32

    Thanks for the nice feedback. If the Pixabay API supports it, It's possible, of course. But as I am currently very busy in my private life, I don't see it happening anytime soon, if I would have to implement it, sorry. Maybe someone from the open source community will see this feature request and jump in, hopefully.

  • First commit to issue fork.
  • Looking at the Pixabay API, they don't return the license, however, we get the original post URL. So we can save that information.
    When it comes to the license, all Pixebay content is under their Content License. So you can use that URL on your page if you want to display the license or even their License Summary.

  • Status changed to Needs review 7 months ago
  • I've implemented saving a URL to the image page, on the media type image. Using Field Mapping in the media type config, you can pick a field (at the moment I limited it to field type link) to which it will save the URL to the original image page.

    So steps to use:

    1. Go to /admin/structure/media
    2. Manage fields for Image
    3. Create a new field of type Link
    4. On the Image edit page, under Field Mapping > Pixabay URL select the newly created field
    5. Any newly added image from Pixabay will automatically set the URL and Original image as title

    This way you can also modify the field display, however you want to, using Manage Display.

  • 🇩🇰Denmark lennart

    Thank you both very much. Can I help test this?

  • Yes of course. Honestly testing as much as possible would be very useful, there might be edge cases I didn't think of when developing.

  • 🇩🇰Denmark lennart

    I think there used to be a "patch" one could apply to test these sorts of things.

    How do I test a pull request? (Sorry, not a programmer)

  • If you find patching easier, you can generate a patch on the merge request page. So on the merge request page, if you click the button "Code", you'll see the patches option under Download. This will download a patch file, that you can apply.

  • 🇮🇳India Vivek Panicker Kolkata

    @admirlju Changes look good.

    I applied the patch, followed your instructions and created the content.
    When I edit the particular media I see the following:

    It looks a bit out of place since it appears in the bottom of the page below the save button.
    Can we fix that?

    Also shouldn't we document the steps in the README file?

  • Hi, so this is the default behavior of entity type form display when you add a new field. And how it currently works it's probably an issue somewhere in the Drupal core.

    If you want to move the links above the save and delete buttons.

    1. Edit the media type.
    2. Go to Manage Form Display
    3. Move the Link field just below the image field
    4. Save changes

    Yeah, I agree about the README. I'll add the steps to it. I just first wanted to make sure it works like it's supposed to.

  • Status changed to Needs work 7 months ago
  • 🇸🇮Slovenia slogar32

    Hey! Thank you for the feature implementation. I quickly went through the changes, could you please:

    • -Make the pixabay URL field map available on all media types with the image source plugin (since the module supports adding of those on the entity browser widget). Use
      $sourcePlugin = $entity->getSource();
      if (!$sourcePlugin instanceof (Drupal\media\Plugin\media\Source\)Image) {
        return;
      }

      instead of

      if ($entity->id() != 'image') {
        return;
      }

      in the form alter hook, that you've implemented.

    • -Use camelCase for the newly defined $pixabay_url_field_name variable in the Pixabay plugin class please (I know $form_state is snake case, but we used camel case throughout the whole class, so it should stay consistent).
    • -Run hpcs --standard=Drupal,>DrupalPractice to see if your code follows Drupal coding standards. Add the "." to the end of the inline comments in the form alter hook, that's what I spotted with my eyes, maybe there's more to fix.

    Otherwise, this looks good!

  • First commit to issue fork.
  • Status changed to Needs review 7 months ago
  • 🇮🇳India ankithashetty Karnataka, India

    Updating MR with changes requested in #13. Thanks!

  • Assigned to slogar32
  • 🇸🇮Slovenia slogar32
  • Issue was unassigned.
  • Status changed to RTBC 4 months ago
  • 🇸🇮Slovenia slogar32

    I tested this with multiple widgets (with each having a different media type with an image source plugin selected). I had to add some edge cases and fix the code quality slightly. I've also updated the readme file. Thank you for your contributions.

  • Status changed to Fixed 4 months ago
  • 🇸🇮Slovenia slogar32
  • 🇸🇮Slovenia slogar32
  • 🇮🇳India Vivek Panicker Kolkata

    @slogar32 Hi!
    It seems neither me or @ankithashetty received any credit for this :|

  • 🇸🇮Slovenia slogar32

    Hello!

    I've assigned credit to this issue, according to How is credit granted for Drupal core issues → . @admirlju got credit because he created the initial solution, @lennart got credit, because of a useful original issue report (see first two bullet points here https://www.drupal.org/about/core/policies/maintainers/how-is-credit-granted-for-drupal-core-issues#receive-credit → ).

    I did not grant you credit because of bullet point 7, 2nd level bullet point 3 here https://www.drupal.org/about/core/policies/maintainers/how-is-credit-granted-for-drupal-core-issues#not-receive-credit → and @ankithashetty, because she did copy paste of my code from the comment, and she also missed some obvious things of the same matter from her copy paste fixes, that I had to fix myself later on (could fall under bullet point number 9 from the last link).

    So basically I had to re-test this whole solution again, and I found further issues, that I also fixed myself. And because of the described things above, I do not see you eligible for credit here, sorry.

    Best regards,
    Domen

  • 🇮🇳India Vivek Panicker Kolkata

    Nice info!
    Thanks for sharing!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024