René's URL Explorer Experiment


Title: Allow for the ngSrc (and other inputs to change) when using NgOptimizedDirective · Issue #47813 · angular/angular · GitHub

Open Graph Title: Allow for the ngSrc (and other inputs to change) when using NgOptimizedDirective · Issue #47813 · angular/angular

X Title: Allow for the ngSrc (and other inputs to change) when using NgOptimizedDirective · Issue #47813 · angular/angular

Description: Which @angular/* package(s) are relevant/related to the feature request? common Description Currently an error is thrown (in dev mode) when one of the inputs changes on an img when when using NgOptimizedImage (the directive) The directiv...

Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? common Description Currently an error is thrown (in dev mode) when one of the inputs changes on an img when when using NgOpt...

X Description: Which @angular/* package(s) are relevant/related to the feature request? common Description Currently an error is thrown (in dev mode) when one of the inputs changes on an img when when using NgOpt...

Opengraph URL: https://github.com/angular/angular/issues/47813

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow for the ngSrc (and other inputs to change) when using NgOptimizedDirective","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\r\n\r\ncommon\r\n\r\n### Description\r\n\r\nCurrently an error is thrown (in dev mode) when one of the inputs changes on an `img` when when using `NgOptimizedImage` (the directive)\r\n\r\nThe directive currently only supports the most basic case of rendered once and only once, but there are many use cases where an image may change (realtime applications for example). Our use case in particular is a website builder that allows the user to edit the page inline (and eventually in realtime). Heres some screenshots from Trellis.org to demonstrate this:\r\n\r\n![image](https://user-images.githubusercontent.com/9469090/196739875-f54bee8a-8ad7-48db-894d-0089cb24dc1d.png)\r\n\r\n![image](https://user-images.githubusercontent.com/9469090/196739914-e4ce1bad-67d2-44e1-997a-d3cdcc25b816.png)\r\n\r\nA user can click to change the media which opens up a photo library using Unsplash and then crops the image, after the server response the `ngSrc` is updated with the new image (currently no other inputs change as the element is a static size)\r\n\r\nCurrently did does not work as inputs are not allowed to change.\r\n\r\nOur rendered live pages (the ones the users of our users end up seeing after the page is finished being built) use the directive already but it would be nice if our website builder itself could be using it as well.\r\n\r\n\r\n\r\n\r\n### Proposed solution\r\n\r\nAllow for the Inputs to change and check and update either all of the attributes or only the ones that would be affected by that specific attribute(s).\r\n\r\nIn `ngOnChanges` instead of throwing an error (we may still want to throw an error for some, like `priority`)  determine what attributes on the `img` tag changed and need to be updated (or just update them all by calling `setHostAttributes()` again.\r\n\r\n### Alternatives considered\r\n\r\n Existing solutions to this are a little hacky and annoying to do but are as such:\r\n\r\n1. Create a directive that manually (with some type coercing) force the directive to rerender (THIS IS HACKY DO NOT DO THIS):\r\nhttps://angular-team.slack.com/archives/C08M4JKNH/p1666193540352369?thread_ts=1666128103.036069&cid=C08M4JKNH\r\n\r\n```typescript\r\nimport { NgOptimizedImage } from '@angular/common';\r\nimport type { OnChanges, SimpleChanges } from '@angular/core';\r\nimport { Directive, inject, Input } from '@angular/core';\r\n\r\n@Directive({\r\n    selector: 'img[imageChange]',\r\n    standalone: true,\r\n})\r\nexport class OptimizedImageChangedDirective implements OnChanges {\r\n    private readonly ngOptimizedImage = inject(NgOptimizedImage);\r\n\r\n    @Input() rawSrc!: string;\r\n\r\n    ngOnChanges(changes: SimpleChanges): void {\r\n        if (changes['rawSrc'] && !changes['rawSrc'].isFirstChange()) {\r\n            (this.ngOptimizedImage as any).setHostAttributes();\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n```angular2html\r\n\u003cimg [ngSrc]=\"media\" imageChange ...other attrs>\r\n```\r\n\r\n2. Wrapping in an `\u003cng-template>` and create an embedded view (as per @AndrewKushnir):\r\nhttps://angular-team.slack.com/archives/C08M4JKNH/p1666132985022759?thread_ts=1666128103.036069&cid=C08M4JKNH\r\n\r\n`You may try wrapping an \u003cimg> into \u003cng-template> in this case and create a view dynamically (via ViewContainerRef.createEmbeddedView) - this would re-create the view containing an \u003cimg> and you can control when this view should be re-created.`","author":{"url":"https://github.com/yharaskrik","@type":"Person","name":"yharaskrik"},"datePublished":"2022-10-19T15:57:28Z","url":"https://github.com/angular/angular/issues/47813"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:268e9ed0-1134-627a-06f1-cbb2c04a7d1e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9BC8:3A73AA:10D60AD:15471FD:6B015115
html-safe-nonce97b5efab1d6ffaa3be6088a755a7f3b2360229e6efc106a0a2cb7204e62b9f05
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkM4OjNBNzNBQToxMEQ2MEFEOjE1NDcxRkQ6NkIwMTUxMTUiLCJ2aXNpdG9yX2lkIjoiMzM1OTg2MTUzNzczMTg1ODcwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac327318703a696df6d7de273696e1a4aca3f62ca653004a8d726e3ad892fa14bd
hovercard-subject-tagissue:1415232356
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/47813/issue_layout
twitter:imagehttps://opengraph.githubassets.com/fc2d06222fa27eeed9b74c1730ce39b0bf251f348fa0bf046e90c4fc128733e9/angular/angular/issues/47813
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/fc2d06222fa27eeed9b74c1730ce39b0bf251f348fa0bf046e90c4fc128733e9/angular/angular/issues/47813
og:image:altWhich @angular/* package(s) are relevant/related to the feature request? common Description Currently an error is thrown (in dev mode) when one of the inputs changes on an img when when using NgOpt...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameyharaskrik
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/47813#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F47813
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F47813
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/47813
Reloadhttps://github.com/angular/angular/issues/47813
Reloadhttps://github.com/angular/angular/issues/47813
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues836 (836)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/47813
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/47813
Allow for the ngSrc (and other inputs to change) when using NgOptimizedDirectivehttps://github.com/angular/angular/issues/47813#top
area: commonIssues related to APIs in the @angular/common packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20common%22
common: image directivehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22common%3A%20image%20directive%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/yharaskrik
yharaskrikhttps://github.com/yharaskrik
on Oct 19, 2022https://github.com/angular/angular/issues/47813#issue-1415232356
https://user-images.githubusercontent.com/9469090/196739875-f54bee8a-8ad7-48db-894d-0089cb24dc1d.png
https://user-images.githubusercontent.com/9469090/196739914-e4ce1bad-67d2-44e1-997a-d3cdcc25b816.png
https://angular-team.slack.com/archives/C08M4JKNH/p1666193540352369?thread_ts=1666128103.036069&cid=C08M4JKNHhttps://angular-team.slack.com/archives/C08M4JKNH/p1666193540352369?thread_ts=1666128103.036069&cid=C08M4JKNH
@AndrewKushnirhttps://github.com/AndrewKushnir
https://angular-team.slack.com/archives/C08M4JKNH/p1666132985022759?thread_ts=1666128103.036069&cid=C08M4JKNHhttps://angular-team.slack.com/archives/C08M4JKNH/p1666132985022759?thread_ts=1666128103.036069&cid=C08M4JKNH
AndrewKushnirhttps://github.com/AndrewKushnir
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
area: commonIssues related to APIs in the @angular/common packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20common%22
common: image directivehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22common%3A%20image%20directive%22
on Oct 19, 2022https://github.com/angular/angular/issues/47813#event-7623428925
ngbothttps://github.com/apps/ngbot
Backloghttps://github.com/angular/angular/milestone/82
on Oct 19, 2022https://github.com/angular/angular/issues/47813#event-7623429389
https://github.com/kbrilla
kbrillahttps://github.com/kbrilla
on Oct 20, 2022https://github.com/angular/angular/issues/47813#issuecomment-1285081731
angular-robothttps://github.com/apps/angular-robot
feature: votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20votes%20required%22
on Oct 20, 2022https://github.com/angular/angular/issues/47813#event-7631683638
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Oct 20, 2022https://github.com/angular/angular/issues/47813#issuecomment-1285625268
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
https://github.com/yharaskrik
yharaskrikhttps://github.com/yharaskrik
on Oct 20, 2022https://github.com/angular/angular/issues/47813#issuecomment-1285669519
@kbrillahttps://github.com/kbrilla
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Nov 29, 2022https://github.com/angular/angular/issues/47813#issuecomment-1330696089
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
angular-robothttps://github.com/apps/angular-robot
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
feature: votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20votes%20required%22
on Dec 14, 2022https://github.com/angular/angular/issues/47813#event-8037565355
https://github.com/vytautas-pranskunas-
vytautas-pranskunas-https://github.com/vytautas-pranskunas-
on Dec 28, 2022https://github.com/angular/angular/issues/47813#issuecomment-1366641170
https://github.com/gizm0bill
gizm0billhttps://github.com/gizm0bill
on Feb 22, 2023https://github.com/angular/angular/issues/47813#issuecomment-1439754750
https://github.com/tomastrajan
tomastrajanhttps://github.com/tomastrajan
on Feb 22, 2023https://github.com/angular/angular/issues/47813#issuecomment-1439814899
https://github.com/exequiel09
exequiel09https://github.com/exequiel09
on Mar 16, 2023https://github.com/angular/angular/issues/47813#issuecomment-1471157376
https://www.npmjs.com/package/ngx-rerenderhttps://www.npmjs.com/package/ngx-rerender
https://github.com/nicholasconfer
nicholasconferhttps://github.com/nicholasconfer
on May 30, 2023https://github.com/angular/angular/issues/47813#issuecomment-1569026454
https://github.com/marcowuethrich
marcowuethrichhttps://github.com/marcowuethrich
on May 30, 2023https://github.com/angular/angular/issues/47813#issuecomment-1569046388
https://github.com/francesco-buscicchio
francesco-buscicchiohttps://github.com/francesco-buscicchio
on Jul 7, 2023https://github.com/angular/angular/issues/47813#issuecomment-1624793314
https://github.com/AndrewKushnir
AndrewKushnirhttps://github.com/AndrewKushnir
on Jul 11, 2023https://github.com/angular/angular/issues/47813#issuecomment-1631483499
#50683https://github.com/angular/angular/pull/50683
https://angular.io/guide/releases#release-schedulehttps://angular.io/guide/releases#release-schedule
#50683https://github.com/angular/angular/pull/50683
AndrewKushnirhttps://github.com/AndrewKushnir
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 11, 2023https://github.com/angular/angular/issues/47813#event-9792092735
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Aug 11, 2023https://github.com/angular/angular/issues/47813#issuecomment-1674073080
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Aug 11, 2023https://github.com/angular/angular/issues/47813#event-10064900850
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/47813
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/47813
area: commonIssues related to APIs in the @angular/common packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20common%22
common: image directivehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22common%3A%20image%20directive%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.